i am trying to make a file and then read it. The file will take the batch no of student, student name and fees. it is a sequential file type. No problem in time of creating file but the problem during reading the file. in time of reading in the console it is reading only the first entry and printing it....not stopping. i am unable to caught the fault. The code has given below.
#include<stdio.h>
int main(void)
{
int batch=0;
char name[100];
float fees=0;
FILE *studentData;
if( (studentData=fopen("studentData.dat","r")) == NULL)
{
puts("Sorry, file opening is not possible.");
}
else
{
printf("%2s%5s%5s\n","Batch","Name","Fees");
fscanf(studentData,"%d%s%f",&batch, name, &fees);
while(!feof(studentData))
{
printf("%d %s %f\n",batch,name,fees);
fscanf( studentData, "%d%s%f",&batch, name, &fees);
}
}
fclose(studentData);
return 0;
}