C语言_手机通讯录代码(全文)
下面是小编为大家整理的C语言_手机通讯录代码(全文),供大家参考。
#include <stdio.h>
#include <string.h>
int count=0;
typedef struct{
char name[10];
int age;
char tel_num[13];
}friends_list,*pfriends_list;
void new_friend(friends_list friend[])
{
if(count==50)
{
printf("名片夹已满\n");
return ;
}
else
{
printf("请输入新建联系人姓名\n");
scanf("%s",friend[count].name);
printf("请输入新建联系人姓名\n");
scanf("%d",&friend[count].age);
printf("请输入新建联系人号码\n");
scanf("%s",friend[count].tel_num);
count++;
}
}
void search_friend(friends_list friend[])
{
if(0==count)
{
printf("名片夹为空\n");
return ;
}
int i=0;
char name[10];
printf("输入姓名:\n");
scanf("%s",name);
for(i=0;i<count;i++)
{
if(strcmp(friend[i].name,name)==0)
{
printf("姓名:%s\n",friend[i].name);
printf("年龄:%d\n",friend[i].age);
printf("号码:%s\n",friend[i].tel_num);
break;
}
}
if(i==count)
{
printf("查无此人\n");
}
}
int main()
{
int select=0;
friends_list friends[50]={0};
do
{
printf("手机通讯录选项:1-新建联系人 2-搜索联系人 0-退出\n");
printf("请输入选择:\n");
scanf("%d",&select);
switch(select)
{
case 0:
break;
case 1:
new_friend(friends);
break;
case 2:
search_friend(friends);
default :
break;
}
}while(select!=0);
printf("谢谢使用\n");
}
推荐访问:C语言_手机通讯录代码 通讯录 语言 代码
热门文章:
- 酒店总经理年度工作总结8篇2024-12-07
- 2023年度大一上学期期末个人总结800字10篇(完整)2024-12-07
- 2023年高三综评期末总结8篇2024-12-07
- 四年级科学的教学总结6篇【精选推荐】2024-12-06
- 期末颁奖总结3篇(范文推荐)2024-12-06
- 医院客服年终个人总结7篇2024-12-06
- 2023年度高校寒假安全教育主题班会总结12篇(2023年)2024-12-06
- 2023年有关学生期末个人总结7篇(范文推荐)2024-12-06
- 2023年度公司业务部年终总结10篇2024-12-06
- 园林绿化有限公司年度工作总结5篇【完整版】2024-12-06
相关文章:
- 想抓读者“胃”,,语言要有“味”,——公文语言“七种味道”2022-09-11
- 2023年度生日语言表达说说,菁选2篇2023-01-31
- 2023年度10个经典C语言小程序(2023年)2023-02-25
- 最新小班语言教学总结,语言教学总结报告(13篇)2023-07-19
- 开展语言文字活动方案(4篇)2023-07-25