C語言實現(xiàn)電話簿管理系統(tǒng)課程設(shè)計
更新時間:2021年11月23日 17:27:40 作者:我慢慢地也過來了
這篇文章主要為大家詳細介紹了C語言實現(xiàn)電話簿管理系統(tǒng)課程設(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)系人不存在,仔細思考一下再輸入吧,親?。?!\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)在的地點:");
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)系人信息不存在,請仔細思考一下,再輸入吧親?。?!\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)系人電話號碼不存在,請仔細思考一下再輸入吧,親?。?!\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)系人不存在,仔細思考一下再輸入吧,親?。?!\n");
system("pause");
system("cls");
//return;
}
}
}
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
C++深入講解namespace與string關(guān)鍵字的使用
namespace命名空間或者叫名字空間,傳統(tǒng)的c++只有一個全局的namespace,namespace引入了復(fù)雜性。namespace允許像類,對象,函數(shù)聚集在一個名字下。本質(zhì)上講namespace是對全局作用域的細分2022-05-05
剖析C++編程當中指針作為函數(shù)參數(shù)的用法
這篇文章主要介紹了剖析C++編程當中指針作為函數(shù)參數(shù)的用法,是C++入門學習中的基礎(chǔ)知識,需要的朋友可以參考下2015-09-09
c語言獲取用戶輸入字符串是scanf和gets的區(qū)別詳解
今天小編就為大家分享一篇c語言獲取用戶輸入字符串是scanf和gets的區(qū)別詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-07-07
codeblocks 對‘cv::waitKey(int)’未定義的引用方式
今天小編就為大家分享一篇codeblocks 對‘cv::waitKey(int)’未定義的引用方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-12-12

