This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
when have to set the eof flag?
- To: STDC++ <libstdc++ at sources dot redhat dot com>
- Subject: when have to set the eof flag?
- From: Levente Farkas <lfarkas at mindmaker dot hu>
- Date: Wed, 25 Jul 2001 14:47:11 +0200
- Organization: Mindmaker Ltd.
- Reply-To: lfarkas at mindmaker dot hu
hi,
what is the "good" result for this code? (other compilers and c++ libs gives
different result:-)
I try to find the appropriate part from the standard but it's not clear
for me.
------------------------
#include <iostream>
#include <string>
#include <sstream>
int main()
{
std::string s( "1234" );
std::istringstream strm( s );
int i = 0;
strm >> i;
//strm >> i >> std::ws;
std::cout << "string: " << s << "\n"
<< "i: " << i << "\n"
<< "strm: good: " << strm.good() << " eof: " << strm.eof()
<< std::endl;
return 0;
}
------------------------
the output is:
string: 1234
i: 1234
strm: good: 1 eof: 0
if I switch to the commented line then eof is true. it's ok. but when
have to set the eof flag. since in the above example the stream pointer
point to the and of file (IMHO).
-- Levente "Si vis pacem para bellum!"