JK> What is the prefered loop for reading to the end of a file?
JK> while (!filestream.eof())
JK> or
JK> while (!filestream.fail())
eof() tells you if the stream has reached its end. fail() tells you if
the last (reading) operation has failed. If you have access to
comp.lang.c++.moderated (or was it comp.std.c++? I don't recall),
there was a discussion ("the good(), the bad() and the fail()") about
these memember functions.
I personally would use the simplest possibility:
while (filestream >> myData)
// work with myData
Thomas
---
þ MM 1.0 #0113 þ The penalty for bigamy is two mothers-in-law.
---------------
* Origin: McMeier & Son BBS (2:301/138)
|