回复 2楼 吹水佬
void save(tele head)
{
FILE *fp;
tele t;
t=head;
if(fp=(fopen("data.txt","a+"))==NULL);
{
printf("打开文件失败!\n");
getch();
exit(0);
}
while(!feof(fp))
{
if(fread(t,sizeof(tele),1,fp)==1)
total++;
}
fclose(fp);
if(total==0)
{
printf("No contact record!\n");
}
else
{
system("cls");
read();
}
if(fp=(fopen("data.txt","wb"))==NULL);
{
printf("can not open address list!\n");
return;
}
fwrite(t,sizeof(tele),1,fp);
printf("文件保存成功!\n");
fclose(fp);
printf("按任意键返回主菜单\n");
getch();
}
然后他一直显示打开文件失败