求高手帮忙 通讯录程序有一个错误 帮帮小弟
#include<stdio.h>#include<string.h>
#define M 3
int Count = 0;
struct friends_list{
char name[10];
char number[13];
};
void new_friend(struct friends_list friends[]);
void search_friend(struct friends_list friends[],char *name);
void Show(struct friends_list friends[]);
int main(void)
{
struct friends_list friends[M];
Show(friends);
return 0;
}
void Show(struct friends_list friends[])
{
int choice;
char name;
do{
printf("手机通讯录功能选项:1:新建2:查询0:退出\n");
printf("请选择功能:");
scanf("%d",&choice);
switch(choice){
case 1:
new_friend(friends);break;
case 2:
printf("请输入要查找的联系人姓名:");
scanf("%s",name);
search_friend(friends,name);
break;
case 0:break;
}
}while(choice!=0);
printf("感谢使用\n");
}
void new_friend(struct friends_list friends[])
{
struct friends_list f;
if (Count == M){
printf("通讯录已满\n");
return;
}
printf("请输入新联系人的姓名:");
scanf("%s",f.name);
printf("请输入新联系人的电话:");
scanf("%s",f.number);
friends[Count] = f;
Count ++;
}
void search_friend(struct friends_list friends[],char *name)
{
int i,flag = 0;
if(Count == 0){
printf("通讯录是空的!\n");
return;
}
for(i=0;i<Count;i++)
if(strcmp(name,friends[i].name)==0){
flag=1;
break;
}
if(flag){
printf("姓名:%s\t",friends[i].name);
printf("电话:%s\t",friends[i].number);
}
else
printf("无此联系人!");
提示说这句有错误 不知道怎么回事 search_friend(friends,name); 求高手指点 小弟先谢谢了
}