I have a file for marks of student as shown as below:
T1 T2 T3 HW1 HW2 HW3 HW4 PRJ
47 17 50 10 10 10 10 68
20 41 40 15 10 10 10 80
but I don't know how the number of students in the class. I try to write a code to read the data from the file but I get infinite loop.
char header[10];
int data;
int a;
int nos=0;
//READ HEADINGS OF THE TABLE
while(fscanf(f1, "%s", header) != '\n')
{
printf("%s \t", header);
}
printf("\n");
//READ DATA OF THE TABLE
while(fscanf(f1, "%d", data) != EOF)
{
for(a=0; a<=7; ++a)
{
printf("%d \t", data);
}
printf("\n");
}
printf("\n");
printf("Number of students in class: %d", nos/8);
system("pause");