you can use the fread in the while, when the eof is read it exits the =
loop
while(fread(&phone, sizeof(struct record), 1, filePtr))
{ =20
printf("%d%s", int, name);
count++;
}
----- Original Message -----=20
From: Sam=20
To: dev...@li...=20
Sent: Saturday, March 17, 2001 6:00 PM
Subject: [Dev-C++] feof question
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
|