I have this function:
What I want is to find the lines in my file that start with an "A". But for some reason this function is only finding the first line that starts with "A", and after it, the error message "segmentation fault" appears. Can someone help me please? Thanks!Code:void count_airplanes(void) { char line[DIML]; char *vn; FILE *f_simulation = NULL; if((f_simulation = fopen("simulation.txt", "r"))==NULL) { printf("Can't open file %s", "simulation.txt"); return; } while(fgets(line, DIML, f_simulation)!= NULL) { vn = fgets(line, DIML, f_simulation); if(vn[0] == 'A') {printf("%s", vn);} }



LinkBack URL
About LinkBacks


