This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

istream && istream_iterator behavior


Hello all,

Here a little program


-------------------------------------------------------
void read2( istream& p_in )
{
	istream_iterator<char>	l_in_ptr( p_in );

	cout << "read2 = `" << (*l_in_ptr) << "'\n";
}


void read1( istream& p_in )
{
	istream_iterator<char>	l_in_ptr( p_in );

	cout << "read1 = `" << (*l_in_ptr) << "'\n";
	read2( p_in );
}


main( void )
{
	read1( cin );
}
-------------------------------------------------------

$ g++ essai.cpp
$ ./a.out
1234
read1 = `1'
read2 = `2'	// ?????? I was expected `1' too

May someone explain me why I've got this output and not
read2 = `1' ??

Is this a correct behavior ?

(I'm using a snapshot of gcc = gcc-20010222 & gcc-c++-20010122)

Laurent Marzullo


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]