学习资料可自行百度或参阅 https://www.cnblogs.com/saolv/p/7793379.html
#include <stdio.h>
char name[20];
int math, computer, english;
int main(void)
{
int idx = 0;
printf("所有学生信息如下:\n");
FILE * fp = fopen("D:\\info.txt", "r");
while (feof(fp) == 0) {
fscanf(fp, "%s\t%d\t%d\t%d\n", name, &math, &computer, &english);
printf("name:%s\t math:%d\t computer:%d\t english:%d\n", name, math, computer, english);
}
printf("以下学生没通过考试\n");
fp = fopen("D:\\info.txt", "r");
while (feof(fp) == 0) {
fscanf(fp, "%s\t%d\t%d\t%d\n", name, &math, &computer, &english);
if(math < 60 || computer < 60 || english < 60 || (math + computer + english) < 210) {
printf("%s\n", name);
idx++;
}
}
printf("没有通过考试的人数: %d\n", idx);
fclose(fp);
return 0;
}