通讯管理系统下面有两个错误已经指出不知道怎么改。请指教
#include<stdio.h>#include<stdlib.h>
#include<string.h>
typedef struct
{
char score;/*编号*/
char name[10];//姓名
char num[15];//号码
char email;//邮箱
char age[8];//年龄
char adds[20];//住址
}Person;
Person per[80];
int menu_select()//菜单显示
{
char c;
do
{
system("cls");
printf("\t\t********通讯录********\n");
printf("\t\t* *\n");
printf("\t\t* 1.显示 *\n");
printf("\t\t* 2.查询 *\n");
printf("\t\t* 3.修改 *\n");
printf("\t\t* 4.添加 *\n");
printf("\t\t* 5.删除 *\n");
printf("\t\t* 6.排序 *\n");
printf("\t\t* 0.退出 *\n");
printf("\t\t**********************\n");
printf("\t\t请您选择(0~6)");
c=getchar();
}while(c<'0'||c>'6');
return(c-'0');
}
int Input(Person per[],int n)
{
int i=0;
char sign,x[10];
while(sign!='n'&&sign!='N')
{
printf("\t编号:");
scanf("\t%d",&per[n+i].score);
printf("\t姓名:");
scanf("\t%s",per[n+i].name);
printf("\t年龄:");
scanf("\t%s",per[n+i].age);
printf("\t电话号码:");
scanf("\t%s",per[n+i].num);
printf("\t通讯住址:");
scanf("\t%s",per[n+i].adds);
printf("\t电子邮箱:");
scanf("\t%s",per[n+i].email);
gets(x);
printf("\n\t是否继续添加?(Y/N)");
scanf("\t%c",&sign);
i++;
}
return(n+i);
}
void Display(Person per[],int n)//
{
int i;
printf("-------------------------------------------------\n");//格式
printf(" 编号 姓名 年龄 电话号码 住址 邮箱");
printf("--------------------------------------------------\n");
for(i=1;i<n+1;i++)
{
printf("%-5d%-8s%-6s%-13s%-15s%-15s",per[i-1].score,per[i-1].name,per[i-1].age,per[i-1].num,per[i-1].adds,per[i-1].email);
if(i>1&&i%10==0)
{
printf("\t--------------------------------------------\n");
printf("\t");
system("pause");
printf("\t---------------------------------------------\n");
}
}
printf("-------------------------------------------------\n");
system("pause");
}
int Delete_a_record(Person per[],int n)//删除记录
{
char s[20];
int i=0,j;
printf("\t请输入想删除记录中的名字:");
scanf("%s",s);
while(strcmp(per[i].name,s)!=0&&i<n)
i++;
if(i==n)
{
printf("\t通讯录中没有此人!\n");
return(n);
}
for(j=i;j<n-1;j++)
{
strcpy(per[j].num,per[j+1].num);
strcpy(per[j].name,per[j+1].name);
strcpy(per[j].age,per[j+1].age);
strcpy(per[j].adds,per[j+1].adds);
strcpy(per[j].email,per[j+1].email);//错误????!!!!!!!
per[j].score=per[j+1].score;
}
printf("\t\t已经成功删除!\n");
return(n-1);
}
void Query_a_record(Person per[],int n)
{
int m;
printf("\t\n请选择查询方式:\n");
printf("\t|---------------------|\n");
printf("\t| 1——姓名 |\n");
printf("\t| 2——电话 |\n");
printf("\t| 3——年龄 |\n");
printf("\t| 4——返回 |\n");
printf("\t|---------------------|\n");
printf("请选择:");
scanf("%d",&m);
while(m!=1&&m!=2&&m!=3&&m!=4)
{
printf("输入错误!");
scanf("%d",&m);
}
if(m==1)
{
char s[20];
int i=0;
printf("\t请输入想查询的姓名:");
scanf("\t%s",s);
while(strcmp(per[i]).name,s)!=0&&i<n)//错误????!!!!!!!
i++;
if(i==n)
{
printf("\t通讯录没有此人\n");
return;
}
printf("\t此人编号:%d\n",per[i].score);
printf("\t此人年龄:%s\n",per[i].age);
printf("\t电话号码:%s\n",per[i].num);
printf("\t通讯地址:%s\n",per[i].adds);
printf("\t电子邮箱:%s\n",per[i].email);
}
}
void Change(Person per[],int n)//修改记录
{
char s[20];
int i=0;
printf("\t请输入想修改的记录的名字:");
scanf("%s",s);
while(strcmp(per[i].name),s)!=0&&i<n)
i++;
if(i==n)
{
printf("\t通讯录中没有此人!\n");
return;
}
printf("\t编号:");
scanf("\t%d",&per[i].score);
printf("\t姓名:");
scanf("\t%s",per[i].name);
printf("\t年龄:");
scanf("\t%s",per[i].age);
printf("\t电话号码:");
scanf("\t%s",per[i].num);
printf("\t通讯地址:");
scanf("\t%s",per[i].adds);
printf("\t电子邮箱:");
scanf("\t%s",per[i].email);
printf("\t修改成功!");
}
void main()
{
int n;
for(;;)
{
switch(menu_select())
{
case 1:
printf("\n\t添加到通讯录\n");
n=Input(pe,n);
break;
case 2:
printf("\n\t\t\t通讯记录表\n");
Display(pe,m);
break;
case 3:
printf("\n\t从通讯录中删除记录\n");
n=Delete_a_record(pe,n);
break;
case 4:
printf("\n\t从通讯录中查找记录\n");
Query_a_record(pe,n);
printf("\t");
system("pause");
break;
case 5:
printf("\n\t修改通讯录中的记录\n");
change(pe,n);
printf("\t");
system("pause");
break;
case 6:
printf("\n\t按编号排序");
sort(pe,n);
printf("\t");
system("pause");
break;
case 0:
printf("\n\t\t谢谢使用,再见!\n");
}
}
}