commit 23ff3bbe4a13b4a6d2c5fc3f165dc33a60b0c563 Author: 18570281412 <1509636344@qq.com> Date: Fri Jan 11 22:19:54 2019 +0800 CNM diff --git a/123.c b/123.c new file mode 100644 index 0000000..ae5d55b --- /dev/null +++ b/123.c @@ -0,0 +1,266 @@ +#include + #include + #include + #include + #define N 15 +struct person + { +char name[10]; +char phone[11]; +char classify[10]; +char email[20]; +}per[N]; +char A[]={"办公型"}; +char B[]={"个人型"}; +char C[]={"商务型"}; +int load()//**********加载函数**********/ +/***********加载所有记录,并且可以返回所有记录的个数********/ +{ +FILE *fp; +int i; +if((fp=fopen("person.txt","r"))==NULL) +{ +printf("\n打开文件失败!\n"); +return 0; +} +for(i=0;!feof(fp);i++) +fscanf(fp,"%s%s%s%s",&per[i].name,&per[i].phone,&per[i].classify,&per[i].email); +fclose(fp); +return(i); + } +/***************查看功能**************/ +int search() +{ +void menu(); +int n,j,k=-1; +char p[10]; +n=load(); +printf("\n\nClassify A:办公型\nClassify B:个人型\nClassify C:商务型\n\n 选择你要查看的分类 分类:"); /*************输入要找的人的分类*********/ +scanf("%s",p); +for(j=0;j=15) +printf("\n\n空间已满无法储存\n\n");/*如果记录多余15条,则提示空间已满*/ +} +else +{ +printf("\n成功!输入分类以及电子邮件:\n"); +/****如果输入的是新信息,则继续输入这个人的分类和电子邮件*****/ +scanf("%s%s",classify,email); +fp=fopen("person.txt","a+"); +fprintf(fp,"\n%s %s %s %s",name,phone,classify,email); } +fclose(fp); +printf("\n输入任意键返回\n"); +getchar(); +getchar(); +system("cls"); +menu(); +} +/****************修改功能************/ +void modify() +{ +void menu() ; + int i,n,j,c; + int k=-1; +char name[10]; +FILE *fp; +n=load(); +printf("\n\n输入要修改人的姓名:\n"); +/*****输入要修改人的姓名******/ +scanf("%s",name); +if((fp=fopen("person.txt","r+"))==NULL) +{ +printf("\n\n打开文件失败!\n\n"); +} +for(j=0;j4||c<1) +{ +puts("\n选择错误,请重新尝试!\n"); +getchar(); +} +} +while(c>4||c<1); +} +if(k==-1) +printf("该联系人不存在!"); +do +{ switch(c) +{ +case 1:printf("name");scanf("%s",per[j].name);break; +case 2:printf("phone");scanf("%s",per[j].phone);break; +case 3:printf("classify");scanf("%s",per[j].classify);break; +case 4:printf("email");scanf("%s",per[j].email);break; +} +} +while(c<1||c>4); +for(i=0;i6) +{w1=1;getchar();} +else w1=0; +} +while(w1==1); +switch(n) +{ +case 1:search();break; /*查看模块*/ +case 2:add();break; /*增加模块*/ +case 3:modify();break; /*修改模块*/ +case 4:del();break; /*删除模块*/ +case 5:browse();break; /*显示模块*/ +case 6:call(); +} +} + + +/***************主函数****************/ + int main () +{ +menu (); +} diff --git a/123.exe b/123.exe new file mode 100644 index 0000000..f16676e Binary files /dev/null and b/123.exe differ diff --git a/123.o b/123.o new file mode 100644 index 0000000..9002ea7 Binary files /dev/null and b/123.o differ