Mail Archives: djgpp/2000/08/09/10:05:57
I seem to be having the same problem using Microsoft VC++ 6.0
to compile a "console application". I called "bad()" after
detecting "eof()" and it returns false (as expected).
Do I need to add "clear()" after eof is detected?
Thanks,
Kent
In article <38nnos876cfdjok9gbkn9sn7968nnjh054 AT 4ax DOT com>,
Jason Green <news AT jgreen4 DOT fsnet DOT co DOT uk> wrote:
> "David Lee" <keeyu AT poetic DOT com> wrote:
>
> > I opened a fstream object and tried to position the file pointer
with seekg
> > ().
> >
> > I found that seekg () always worked as long as eof () was not
encountered.
> > Once eof () holds, it would appear to work as usual, but subsequent
reading
> > from the fstream object were wrong.
> >
> > Any idea?
>
> You are not checking the stream for errors. The stream state can be
> tested with (f), f.good(), f.eof(), f.fail() & f.bad(), which each
> have a specific meaning.
>
> My C++ reference says that if fail() is true the next operation will
> fail. The state bits can be reset with f.clear().
>
Sent via Deja.com http://www.deja.com/
Before you buy.
- Raw text -