|
From: BoB S. <squ...@ya...> - 2001-03-19 02:14:08
|
I believe it is because C++ encounters the eof
marker AFTER it tries to read past the last item in
the file. Therefore you should be testing for the eof
after u read from the file each time rather than
before. Correct me if im wrong anyone please.
Sev
--- Sam <sch...@ho...> wrote:
> I'm trying to read through a file using the
> following statement:
>
> while(!feof(filePtr)
> {
> fread(&phone, sizeof(struct record), 1, filePtr);
> printf("%d%s", int, name);
> count++;
> }
>
> The problem is that it reads the last record twice
> and increments the count one more time than needed.
> Could someone explain why this happens and how to
> avoid it using the feof function? Thanks.
>
> Sam
>
__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail.
http://personal.mail.yahoo.com/
|