我正在读取带有fgets的文件,但是到达文件末尾时它不会停止。
if (fgets(fileLine, 100, fp) != NULL && !feof(fp) && !ferror(fp) ) {//none of them whould stop reading the file, if statement should break with fileLine == NULL
sscanf(fileLine,"%s %d, %s %s %d",temp[0], &frameNumber, temp[1],temp[2], &destinationFrame); //if fileLine != NULL, this line works normally. when the end of file is reached, fileLine is actually null, so causing a segmentation fault
}