commit 48f57d9dc92ffb654a9066984170eea8f646744f Author: unknown <18408000602@stu.hut.edu.cn> Date: Thu Jan 3 15:46:57 2019 +0800 first commit diff --git a/通讯录.c b/通讯录.c new file mode 100644 index 0000000..b15eba2 --- /dev/null +++ b/通讯录.c @@ -0,0 +1,103 @@ +#include +#include +#include +#include +//¶¨Ò庯Êý +FILE *fp; //ÎļþÖ¸Õë +void menu(); +void add(); +void search(); +void modify(); +void look(); +void quit(); +//Ö÷º¯Êý +int main() +{ + menu(); + return 0; +} +//ͨѶ¼½á¹¹Ìå +struct user +{ + char name[8]; //ÐÕÃû + char place[15]; //¼®¹á + char tel1[15]; //µç»°1 + char tel2[15]; //µç»°2 + char email[20]; //µç×ÓÓÊÏä +}user[50]; +//²Ëµ¥ +void menu() +{ + system("cls"); + system("color f3"); + int n; + printf("\n\n\n\n\n"); + printf("\t\t:---------ͨѶ¼---------:\n"); + printf("\t\t: 1:н¨ :\n"); + printf("\t\t: 2:²éѯ :\n"); + printf("\t\t: 3:ÐÞ¸Ä :\n"); + printf("\t\t: 4:ä¯ÀÀ :\n"); + printf("\t\t: 5:Í˳ö :\n"); + printf("\t\t:--ÊäÈëÊý <1-5>Ñ¡Ôñ¹¦ÄÜ--:\n\n"); + scanf("%d",&n); + switch(n) + { + case 1: add(); break; //Ìí¼Ó + case 2: search(); break; //²éѯ + case 3: modify(); break; //ÐÞ¸Ä + case 4: look(); break; //ä¯ÀÀ + case 5: return; break; //Í˳ö + default: return; + } +} +//Ìí¼ÓÓû§ÐÅÏ¢ +void add() +{ + struct user one; + system("color e3"); + if((fp=fopen("user.txt","ab"))==NULL) + { + printf("´ò¿ªÎļþʧ°Ü£¡\n"); + exit(0); + } + printf("\nÇëÊäÈëÓû§ÐÕÃû£º"); + scanf("%s",one.name); + printf("\nÇëÊäÈëÓû§¼®¹á£º"); + scanf("%s",one.place); + printf("\nÇëÊäÈëÓû§µç»°ºÅÂë1£º"); + scanf("%s",one.tel1); + printf("\nÇëÊäÈëÓû§µç»°ºÅÂë2£º"); + scanf("%s",one.tel2); + printf("\nÇëÊäÈëÓû§µç×ÓÓÊÏ䣺"); + scanf("%s",one.email); + fwrite(&one,sizeof(struct user),1,fp); //°ÑÊý¾Ý¿é¼Èëuser.txtÖÐ + fclose(fp); + printf("\n×¢²á³É¹¦£¡\n"); + system("pause"); + menu(); +}; + +//ÐÞ¸Ä +void modify() +{ + + menu(); +} +//²éѯ +void search() +{ + + menu(); +} +//ä¯ÀÀ +void look() +{ + + menu(); + return; +} +//Í˳ö +void quit() +{ + return; +}