Thursday, August 7, 2008

53rd qs.

There were 10 records stored in “somefile.dat” but the following program printed 11 names. What went wrong?
void main()

{
struct student
{
char name[30], rollno[6];
}stud;
FILE *fp = fopen(“somefile.dat”,”r”);
while(!feof(fp))
{
fread(&stud, sizeof(stud), 1 , fp);
puts(stud.name);
}
}

No comments: