卓迈文档网
当前位置 首页 >专题范文 > 公文范文 >

C语言_手机通讯录代码(全文)

发布时间:2022-10-24 08:55:08 来源:网友投稿

下面是小编为大家整理的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语言_手机通讯录代码 通讯录 语言 代码

Top