> Yes, but Im confused about the idea of f.eof(). For 
> example I put 6 element to a file. Ive read the 6th 
> element. If i test f.eof(), will it return false, or do I 
> have to read it one more time, and then test f.eof()?

I'm not sure how C++ does it, but the equivalent in C, 
feof(), will return non-zero (meaning end-of-file) if and 
only if you try to read PAST the end of the file. You must 
then discard that last element you tried to read. So in your 
example of a file containing 6 elements, 7 elements must be 
read; the first 6 will be okay, but the 7th must be 
discarded.

The idea is that feof() cannot know it has reached the end 
of the file until it sees that an error condition has 
occurred. It doesn't look ahead at all. Remember C is a 
low-level language. :-)

David

Reply via email to