How to clear just the eof flag of a file stream

i tried doing this:
1
2
if ( (file.rdstate() & fstream::eofbit) != 0 )
    file.clear(fstream::eofbit);


But it does not seem to work.
I don't want to clear all the states, just the eofbit state.

Thank you very much.
would this do it:
1
2
if ( (file.rdstate() & fstream::eofbit) != 0 )
        file.clear(file.rdstate() & fstream::failbit & fstream::badbit & fstream::goodbit);
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
Topic archived. No new replies allowed.