Code:
#include <stdio.h>


int main(void)
{
        int numstudents, totalstudents = 0, gradesum, totalsum = 0, highscore = 0, totalhs = 0, cavg, highestavg = 0, totalavg, class, x, highavgclass;
        char fihs, sihs;


        for(class = 1; class < 5; class++)                                                                      //Repeats for the # of classes
        {
                totalhs = 0;
                printf("How many students for this class?:");
                scanf("%d", &numstudents);


                        for(x = 1; x <= numstudents; x++)                                                       //Repeated Input per class
                        {
                                char fi, si;
                                int tempscore;


                                printf("\nEnter data for student %d.  (F.I., S.I., score b/w 0 and 100):", x);
                                scanf("%c, %c, %d", fi, si, tempscore);


                                FILE *ofp;
                                ofp = fopen("errorfile.txt", "w");


                                if(0 < tempscore < 100)
                                        gradesum += tempscore;
                                else{
                                        fprintf(ofp, "Student Inititals:%c.%c.\nScore:%d", fi, si, tempscore);
                                        printf("Error, score not in range.  Reinput student information");
                                        x--;
                                        continue;
                                }
                                        if(tempscore > highscore){
                                        fihs = fi;
                                        sihs = si;
                                        highscore = tempscore;
                                }
                        }


                cavg = gradesum / numstudents;
                printf("\nClass Average: %d\nStudent with Highest Score:%c.%c.\nStudent's Score:%d", cavg, fihs, sihs, highscore);


                totalsum += gradesum;
                totalstudents += numstudents;
                if(cavg > highestavg){
                        highestavg = cavg;
                        highavgclass = class;
                }
                if(highscore > totalhs)
                        totalhs = highscore;


        }


        totalavg = totalsum / totalstudents;


        printf("\nTotal Average for All Classes: %d\nHighest Class Average: Class %d with a %d Average\nHighest Overall Grade: %c.%c. with a %d",
totalavg, highavgclass, highestavg, fihs, sihs, totalhs);


return 0;
}
I run the program and right after outputting "Enter data for student 1 .................." i get the seg fault. I'm pretty darn new to C so I have no idea what this means, but since its my first time with file input and output i think it might be that, but I commented those parts out and still got the error. Help please?