This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
istream && istream_iterator behavior
- To: "Libstdc++" <libstdc++ at gcc dot gnu dot org>
- Subject: istream && istream_iterator behavior
- From: "Laurent Marzullo" <laurent dot marzullo at be dot sema dot com>
- Date: Fri, 23 Feb 2001 12:58:25 +0100
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