bug in iostreams???
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Wed Jul 21 23:21:00 GMT 1999
> The obvious problem is that after reading 4 bytes from
> the input stream buffer the rest of the chars are gotten
> rid of.
>
> Any ideas for a fix? :>
No, the problem is that the stream has failed if you can't read a full
line. To read the rest, you have to write
if ( cin.rdbuf()->in_avail() )
{
if (cin.fail())
cin.clear(cin.rdstate() & ~ios::failbit);
cin.getline( buff, cin.rdbuf()->in_avail() );
cout << "what remains is \"" << buff << "\"" << endl;
}
Regards,
Martin
More information about the Gcc-bugs
mailing list