优化交互 修改当数据文件不存在时的处理

master
ithg 7 years ago
parent 708cdf83e6
commit 741eaf6c0e

@ -136,12 +136,12 @@ void Save() //
if ((fp1 = fopen("sql.txt", "wb")) == NULL) if ((fp1 = fopen("sql.txt", "wb")) == NULL)
{ {
printf("车次数据文件不存在\n"); printf("车次数据文件不存在\n");
exit(0); Menu();
} }
if ((fp2 = fopen("num.txt", "wb")) == NULL) if ((fp2 = fopen("num.txt", "wb")) == NULL)
{ {
printf("车次序号数据文件不存在\n"); printf("车次序号数据文件不存在\n");
exit(0); Menu();
} }
printf("数据保存中,请稍后\n"); printf("数据保存中,请稍后\n");
fwrite(&class_num, sizeof(int), 1, fp2); //写入文件信息 fwrite(&class_num, sizeof(int), 1, fp2); //写入文件信息
@ -157,14 +157,14 @@ void Load() //
system("cls"); system("cls");
printf("车次数据文件不存在\n"); printf("车次数据文件不存在\n");
system("pause"); system("pause");
exit(0); Menu();
} }
if ((fp2 = fopen("num.txt", "rb+")) == NULL) if ((fp2 = fopen("num.txt", "rb+")) == NULL)
{ {
system("cls"); system("cls");
printf("车次序号数据文件不存在\n"); printf("车次序号数据文件不存在\n");
system("pause"); system("pause");
exit(0); Menu();
} }
fread(&class_num, sizeof(int), 1, fp2); //读入信息 fread(&class_num, sizeof(int), 1, fp2); //读入信息
fread(records, sizeof(CLASS), class_num, fp1); //读入信息 fread(records, sizeof(CLASS), class_num, fp1); //读入信息

Loading…
Cancel
Save