这是我用来从文件读取结构数组的函数。所有" printf"语句用于调试目的。
int read_processes(process list[], int count) {
char file_name[80];
FILE *file;
printf ("Enter file name: ");
scanf ("%s", file_name);
//executes block if file is opened properly
if ((file = fopen(file_name, "r")) != NULL) {
printf("before fscanf\n");
while (!feof(file) && (count < 100)) {
printf ("Middle of fscanf\n");
fscanf(file, "%s", list[count].name);
printf ("Name is %s\n", list[count].name);
fscanf(file, "%d", list[count].arrival_time);
printf ("Arrival time is %d\n", list[count].arrival_time);
fscanf(file, "%d\n", list[count].execution_time);
printf ("Execution time is %d\n", list[count].execution_time);
fscanf(file, "%d\n", list[count].priority);
printf ("Priority is %d\n", list[count].priority);
count++; //count will be number of items in array
printf("after fscanf %d\n", count);
}
printf ("after EOF\n");
fclose(file);
return 1;
}
//returns zero if file is not opened properly
else {
return 0;
}
}
该功能在&#34; printf后停止(&#34;名称为%s \ n&#34;,列表[count] .name);&#34;线。我做错了什么?