void show() {
FILE* fp;
int ch;
int stupos = 0;
fp = fopen("C:\\Users\\ALIENWARE\\Desktop\\student.txt", "r");//以r模式打开文件
if (!fp)
return;
while (EOF != (ch = fgetc(fp))) {
if (ch == 10) {
stupos++;
}
putchar(ch);
}
TotalCount = stupos;
printf_s("一共有%d名学生", TotalCount);
fclose(fp);
}
测试没问题。可能在别的代码里?