本文實(shí)例為大家分享了C語言課程設(shè)計:電話簿管理系統(tǒng),供大家參考,具體內(nèi)容如下:
文件目錄:
初始界面
現(xiàn)在顯示一部分代碼:
//添加聯(lián)系人 void add() { int i; FILE *fp1;//定義文件指針fp1,使其指向電話簿文本文件 fp1=fopen("電話簿.txt","a+"); printf("請輸入要增加的聯(lián)系人的個數(shù):"); scanf("%d",&n); for(i=num;i<num+n;i++) { printf("請輸入要增加的聯(lián)系人的姓名:\n"); scanf("%s",person[i].name); printf("請輸入要增加的聯(lián)系人的家鄉(xiāng):\n"); scanf("%s",person[i].hometown); printf("請輸入要增加的聯(lián)系人的電話號碼:\n"); scanf("%s",person[i].telephone); true_phone(person[i].telephone); printf("請輸入要增加的聯(lián)系人的郵件:\n"); scanf("%s",person[i].Email); } for(i=num;i<num+n;i++) { fprintf(fp1,"%s\t%s\t%s\t%s\t",person[i].name,person[i].hometown,person[i].telephone,person[i].Email); } printf("恭喜您,成功添加%d位聯(lián)系人",n); num=num+n; fclose(fp1); save(); saveuu(); } //查找聯(lián)系人函數(shù) void find() { int select; system("cls"); while(1) { findmenu(); scanf("%d",&select); switch(select){ case 1: namefind();system("cls"); break; case 2: hometownfind();system("cls");break; case 3: mohufind();system("cls");break; //case 4: //Emailfind();system("cls");break; case 4: system("cls");return; default: print_error(); system("cls"); break; } system("cls"); } }
//修改聯(lián)系人姓名 void modify_name() { int i; char str[20]; printf("請主人輸入原來的姓名:"); scanf("%s",str); for(i=0;i<num;i++) { if(strcmp(person[i].name,str)==0) { printf("請主人輸入現(xiàn)在的新名字:"); scanf("%s",str); if(strcmp(person[i].name,str)==0) { printf("對不起,主人,您輸入的姓名與原來的姓名重復(fù),請重新輸入吧!\n"); system("pause"); system("cls"); //return; } else { strcpy(person[i].name,str); printf("恭喜您主人,修改名字成功啦!!!\n"); system("pause"); system("cls"); //return; } save(); return; } if(i==num-1) { printf("主人,您要修改的聯(lián)系人不存在,仔細(xì)思考一下再輸入吧,親!!!\n"); system("pause"); system("cls"); //return; } } } //修改聯(lián)系人家鄉(xiāng) void modify_hometown() { int i; char str[20]; printf("請主人輸入修改聯(lián)系人的姓名:"); scanf("%s",str); for(i=0;i<num;i++) { if(strcmp(person[i].name,str)==0) { printf("請主人輸入聯(lián)系人現(xiàn)在的地點(diǎn):"); scanf("%s",str); if(strcmp(person[i].hometown,str)==0) { printf("對不起,主人,您輸入的家鄉(xiāng)與原來的重復(fù),請重新輸入吧!\n"); system("pause"); system("cls"); //return; } else { strcpy(person[i].hometown,str); printf("恭喜您,主人,家鄉(xiāng)修改成功!!!\n"); system("pause"); system("cls"); } save(); return; } if(i==num-1) { printf("主人,您要修改的聯(lián)系人信息不存在,請仔細(xì)思考一下,再輸入吧親!!!\n"); system("pause"); system("cls"); } } } //修改聯(lián)系人電話號碼 void modify_telephone() { int i; char str[20]; printf("請主人輸入修改聯(lián)系人的姓名:"); scanf("%s",str); for(i=0;i<num;i++) { if(strcmp(person[i].name,str)==0) { printf("請主人輸入聯(lián)系人現(xiàn)在的電話號碼:"); scanf("%s",str); if(strcmp(person[i].telephone,str)==0) { printf("對不起,主人,您輸入的電話號碼與原來的重復(fù),請重新輸入吧!\n"); system("pause"); system("cls"); return; } else { strcpy(person[i].telephone,str); printf("恭喜您,主人,聯(lián)系人電話號碼修改成功啦!!!\n"); system("pause"); system("cls"); } save(); return; } if(i==num-1) { printf("主人,您要修改的聯(lián)系人電話號碼不存在,請仔細(xì)思考一下再輸入吧,親!!!\n"); system("pause"); system("cls"); } } } //修改聯(lián)系人郵件 void modify_Email() { int i; char str[20]; printf("請主人輸入聯(lián)系人的姓名:"); scanf("%s",str); for(i=0;i<num;i++) { if(strcmp(person[i].name,str)==0) { printf("請主人輸入現(xiàn)在的新郵件:"); scanf("%s",str); if(strcmp(person[i].Email,str)==0) { printf("對不起,主人,您輸入的郵件與原來的郵件重復(fù),請重新輸入吧!\n"); system("pause"); system("cls"); //return; } else { strcpy(person[i].Email,str); printf("恭喜您主人,修改郵件成功啦!!!\n"); system("pause"); system("cls"); //return; } save(); return; } if(i==num-1) { printf("主人,您要修改的聯(lián)系人不存在,仔細(xì)思考一下再輸入吧,親!!!\n"); system("pause"); system("cls"); //return; } } }
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。
原文鏈接:https://blog.csdn.net/m0_46529566/article/details/121410971