How to clear just the eof flag of a file stream

Nov 25, 2010 at 6:32pm
i tried doing this:
1
2
if ( (file.rdstate() & fstream::eofbit) != 0 )
    file.clear(fstream::eofbit);


But it does not seem to work.
Nov 25, 2010 at 7:20pm
I don't want to clear all the states, just the eofbit state.

Thank you very much.
Nov 25, 2010 at 7:27pm
would this do it:
1
2
if ( (file.rdstate() & fstream::eofbit) != 0 )
        file.clear(file.rdstate() & fstream::failbit & fstream::badbit & fstream::goodbit);
Nov 25, 2010 at 10:40pm
XOR: file.clear( file.rdstate() ^ fstream::eofbit ); will toggle the eofbit
AND NOT: file.clear( file.rdstate() & ~fstream::eofbit ); will toggle set eofbit to 0 in any case
Last edited on Nov 25, 2010 at 10:41pm
Topic archived. No new replies allowed.