I'm working with ifstream
. I read until EOF bit is set (I need this way).
Why then don't work this:
// IN is ifstream file. CH is char.
if (IN.eof()) {
IN.seekg(ios::beg);
IN.clear();
if (read((char*)&CH, sizeof(CH)))
cout << "Succes.";
else
cout << "Not S.";
}
The read
function isn't success anytime. I try use IN.setstate(ifstream::goodbit)
instead IN.clear()
too. But it is the same, am I right?