How can I read data from file ? I can't fix it : <p>I record students informations to txt file but when I want to read data's from file 
just read information's in the first row. Also I calculate the average of the students but when ı want to read average it's not working.</p>

<pre><code>    FILE *fout;
fout = fopen("English Class.txt","w"); 

printf("Please enter student number of class : ");
scanf("%d", &amp;x.classNum);

fprintf(fout, "Class Number : %d\n",x.classNum);

for(i=0; i&lt;x.classNum; i++){

    printf("Please Enter %d.Student Name : ",i+1);
    scanf("%s",&amp;x.Name);

    printf("Please Enter %d.Student Surname : ",i+1);
    scanf("%s",&amp;x.Surname);

    printf("Please Enter %d.Student Number : ",i+1);
    scanf("%d",&amp;x.StudentNumber);

    printf("Please Enter %d.Student Score : ",i+1);
    scanf("%d",&amp;x.EnglishScore);

    x.total = x.total + x.EnglishScore;

    fprintf(fout, "\nStudent Name : %s %s Student Number : %d Student Score : %d\n", x.Name, x.Surname, x.StudentNumber, x.EnglishScore);
 }

x.average = x.total / x.classNum;

fprintf(fout, "\n\nClass Average is : %f", x.average);

fclose(fout);   
</code></pre>

<p>I get students records from top code</p>

<pre><code>        FILE *fin;
    fin = fopen("English Class.txt","r");


    fscanf(fin, "Class Number : %d\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f",&amp;x.classNum, &amp;x.Name, &amp;x.Surname, &amp;x.StudentNumber, &amp;x.EnglishScore, &amp;x.average);
    fclose(fin);            


    printf("Class Number : %d\n", x.classNum);

    for(i=0; i&lt;x.classNum; i++){

    fscanf(fin, "\nStudent Name : %s %s Student Number : %d Student Score : %d\n\nClass Average is : %f", &amp;x.Name, &amp;x.Surname, &amp;x.StudentNumber, &amp;x.EnglishScore);
    fclose(fin);    

    printf("\nStudent Name : %s %s Student Number : %d Student Score : %d\n", x.Name, x.Surname, x.StudentNumber, x.EnglishScore);  

    }

    printf("\n\nClass Average is : %f", x.average);
</code></pre>
