M
Marc Schellens
The following routine ends up always the fail bit set.
I can extract from the same stream e.g. floats without a problem
(so it cannot be the stream)
Any obivious thing I missed?
Thanks,
marc
const string ReadLine(istream& is)
{
static stringstream ioss;
ioss.str("");
is.get( *ioss.rdbuf());
if ( (is.rdstate() & ifstream::failbit ) != 0 )
cout << "failbit\n";
if ( (is.rdstate() & ifstream::badbit ) != 0 )
cout << "badbit\n";
if ( (is.rdstate() & ifstream::eofbit ) != 0 )
cout << "eofbit\n";
if( !is.eof()) is.get(); // remove delimiter
cout << "Read line: " << ioss.str();
return ioss.str();
}
I can extract from the same stream e.g. floats without a problem
(so it cannot be the stream)
Any obivious thing I missed?
Thanks,
marc
const string ReadLine(istream& is)
{
static stringstream ioss;
ioss.str("");
is.get( *ioss.rdbuf());
if ( (is.rdstate() & ifstream::failbit ) != 0 )
cout << "failbit\n";
if ( (is.rdstate() & ifstream::badbit ) != 0 )
cout << "badbit\n";
if ( (is.rdstate() & ifstream::eofbit ) != 0 )
cout << "eofbit\n";
if( !is.eof()) is.get(); // remove delimiter
cout << "Read line: " << ioss.str();
return ioss.str();
}