代码很简单就是不知道为啥出错了。
void History() //输出历史成绩
{
FILE* fp, * fp1;
int s, a;
if (!(fp = fopen("D:\\score.txt", "r")))
{
cout << "无法打开成绩信息文件!" << endl;
exit(-1);
}
cout << "历史成绩显示如下:" << endl;
while (!feof(fp))
{
fscanf(fp, "%d", &s);
cout << s << endl;
}
fclose(fp);
if (!(fp1 = fopen("D:\\average.txt", "r")))
{
cout << "无法打开平均成绩文件!" << endl;
exit(-1);
}
fscanf(fp1, "%d", &a);
cout << "平均为:" << a << endl << endl;
fclose(fp1);
}