Skip to content
Prev 207390 / 398506 Next

End of File for binary files

On 24/01/2010 12:15 PM, Henrik Bengtsson wrote:
I read the passage above to say I might get more than n strings from a 
file containing n of them if they are too long; I don't see it saying 
that I would ever get fewer than n if there are n properly terminated 
strings remaining in the file.

EOF is not the only case in general where you'd get fewer than n strings 
(e.g. a non-blocking connection will only return what's in the buffer), 
but in the usual case of reading from a file, it should be safe.

If you are worried about some particular case, check the source code. 
It's always the final arbiter.

Duncan Murdoch