|
From: Robert D B. <lon...@ju...> - 2001-03-17 18:20:17
|
The last file is read then you do the next while with the EOF pointing to
the last record.
Use
do
{
.......
}while(!feof(filePtr));
On Sat, 17 Mar 2001 13:00:39 -0500 "Sam" <sch...@ho...> writes:
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 |