master
parent 95d75d017c
commit 994488231f

@ -47,7 +47,7 @@ void main()
break; break;
case 5:b=shanchu(p); case 5:b=shanchu(p);
break; break;
case 6:printf("感谢您的使用"); case 6:printf("感谢您的使用!");
break; break;
default:printf("请输入正确的序号:\n"); default:printf("请输入正确的序号:\n");
break; break;
@ -118,7 +118,7 @@ void liulan(FILE *p)
} }
void chaxun(FILE *p) void chaxun(FILE *p)
{ {
int i=0; int xuhao1=0;
p=fopen("txl.sto","rb+"); p=fopen("txl.sto","rb+");
if(p==NULL) if(p==NULL)
{ {
@ -137,12 +137,12 @@ void chaxun(FILE *p)
{ {
printf("姓名: 籍贯: 电话号码1: 电话号码2: 邮箱:\n"); printf("姓名: 籍贯: 电话号码1: 电话号码2: 邮箱:\n");
printf("%s %s %lld %lld %s\n",lxr.name,lxr.jiguan,lxr.num1,lxr.num2,lxr.email); printf("%s %s %lld %lld %s\n",lxr.name,lxr.jiguan,lxr.num1,lxr.num2,lxr.email);
i=i+1; xuhao1=xuhao1+1;
} }
fread(&lxr,sizeof(lxr),1,p); fread(&lxr,sizeof(lxr),1,p);
} }
if(i==count&&(strcmp(mingzi,lxr.name)!=0)) if(xuhao1==count&&(strcmp(mingzi,lxr.name)!=0))
printf("无该联系人\n"); printf("无该联系人\n");
fclose(p); fclose(p);
} }
@ -175,10 +175,10 @@ void xiugai(FILE *p)
printf("6.取消\n"); printf("6.取消\n");
while(next=='Y') while(next=='Y')
{ {
int c; int xuhao;
printf("请输入序号:"); printf("请输入序号:");
scanf("%d",&c); scanf("%d",&xuhao);
switch(c) switch(xuhao)
{ {
case 1:printf("请修改姓名:"); case 1:printf("请修改姓名:");
scanf("%s",lxr.name); scanf("%s",lxr.name);
@ -187,15 +187,17 @@ void xiugai(FILE *p)
scanf("%s",lxr.jiguan); scanf("%s",lxr.jiguan);
break; break;
case 3:printf("请修改电话号码1:"); case 3:printf("请修改电话号码1:");
scanf("%s",lxr.num1); scanf("%lld",&lxr.num1);
break; break;
case 4:printf("请修改电话号码2:"); case 4:printf("请修改电话号码2:");
scanf("%s",lxr.num2); scanf("%lld",&lxr.num2);
break; break;
case 5:printf("请修改邮箱:"); case 5:printf("请修改邮箱:");
scanf("%s",lxr.email); scanf("%s",lxr.email);
break; break;
default:printf("输入错误"); case 6:break;
default:printf("输入错误\n");
break; break;
} }
printf("继续修改:Y\n停止修改:其他字母\n"); printf("继续修改:Y\n停止修改:其他字母\n");
@ -223,6 +225,7 @@ int shanchu(FILE *p)
{ {
printf("通讯录为空,请建立新联系人!\n"); printf("通讯录为空,请建立新联系人!\n");
fclose(p); fclose(p);
getchar();
return 0; return 0;
} }
else else
@ -230,7 +233,7 @@ int shanchu(FILE *p)
person b; person b;
person blank={}; person blank={};
char name[20]; char name[20];
int c=0; int jishu=0;
rewind(p); rewind(p);
printf("请输入您要删除的联系人名称:"); printf("请输入您要删除的联系人名称:");
scanf("%s",name); scanf("%s",name);
@ -244,12 +247,12 @@ int shanchu(FILE *p)
fwrite(&blank,sizeof(blank),1,p); fwrite(&blank,sizeof(blank),1,p);
printf("删除成功!\n"); printf("删除成功!\n");
fclose(p); fclose(p);
c=c+1; jishu=jishu+1;
return 0; return 0;
} }
} }
if(c==count&&(strcmp(name,b.name)!=0)) if(jishu==count&&(strcmp(name,b.name)!=0))
printf("无该联系人!\n"); printf("无该联系人!\n");
fclose(p); fclose(p);
return 0; return 0;

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save