Re: ifstream eof not reporting eof?
On Jun 13, 7:22 pm, "Victor Bazarov" <v.Abaza...@comAcast.net> wrote:
SpreadTooThin wrote:
[...]
So? 'ifstream' has 'good()' member, and it has conversion to 'void*',
so you can do
while (i.read(buff, 2))
or
while (i.read(buff, 2).good())
No, no, no, no. There is *never* any time that ios::good()
should be used, since it returns false if eofbit is set (and so
may return false when the read actually succeeds).
How do I go about checking that the data was actually read and what
the heck is wrong with eof?
Nothing the heck is wrong with eof.
Nothing that it would be possible to fix, you mean. A
predictive EOF would in fact be very nice. In the distant past,
some languages (e.g. Pascal) have tried to specify it. In the
end, it never worked correctly; it's nice, but no one knows how
to specify it so that it is both useful and implementable.
You probably don't understand
how to use it. Try RTFM. Pay specific attention to what flags are
set when 'read' succeeds and/or when it fails, or when it reads less
than requested.
And pay specific attention to what flags are tested by each
function as well:-). The basic philosophy of not supporting
predictive EOF is quite justifiable, given the experience of
other languages. The choice and naming of the functions in ios
a lot less so.
--
James Kanze (GABI Software, from CAI) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34