eof character

Started by
12 comments, last by Zahlman 15 years, 9 months ago
but using your method ToohrVyk, could the flag have been any of the following

eofbit The end of the source of characters is reached during its operations.
failbit No characters were extracted because the end was prematurely found.Notice that some eofbit cases will also set failbit.
badbit An error other than the above happened.

where as using the above, it detects the eof flag?
Advertisement
What do you want to do when you encounter an error while reading?
so getline() returns the istream object.


So by the statement


while (getline(objfile, fullLine))
{
...
}


will that return false if any of the flags are set? which is the same as objfile.good() i believe.

Im just trying to test for end of file, but i would also like a better under standing of the functions.
Quote:Original post by wforl
so getline() returns the istream object.


So by the statement


while (getline(objfile, fullLine))
{
...
}


will that return false if any of the flags are set? which is the same as objfile.good() i believe.


Yep. It's a standard idiom.

Quote:Im just trying to test for end of file, but i would also like a better under standing of the functions.


And if the badbit or failbit get set instead, would you really like to do something different? :)

This topic is closed to new replies.

Advertisement