大家帮忙改改这个简易通讯录哪错了?
按‘0’退出时有问题,大家帮忙改改~~#include"stdio.h"
#include"stdlib.h"
void cj();
void ck();
struct human
{
char name[20];
char sex[4];
char jg[10];
char dz[30];
char qq[20];
char tel[20];
}hu[100];
int i=0;
main()
{
int choice;
char *p;
for(;;)
{
printf("1.创建联系人\n");
printf("2.查询联系人\n");
printf("3.添加联系人\n");
printf("0.退出!\n");
scanf("%d",&choice);
switch(choice)
{
case 1: cj();break;
case 2: ck();break;
case 3: cj();break;
case 0: return;
default:printf("无效输入!!!");
break;
}
printf("真的要退出?(Y/N)?");
scanf("%c",p);
if(*p=='y'||*p=='Y')
break;
else
continue;
}
}
void cj()
{
printf("请输入联系人姓名:\n");
scanf("%s",hu[i].name);
printf("请输入联系人性别:\n");
scanf("%s",hu[i].sex);
printf("请输入联系人籍贯:\n");
scanf("%s",hu[i].jg);
printf("请输入联系人地址:\n");
scanf("%s",hu[i].dz);
printf("请输入qq:\n");
scanf("%s",hu[i].qq);
printf("请输入电话:\n");
scanf("%s",hu[i].tel);
i++;
}
void ck()
{
int a;
printf("查看几号联系人:\n");
scanf("%d",&a);
if(i>0&&a<i)
{
printf("%d号联系人:\n",a);
printf("姓名:%s\n",hu[a].name);
printf("性别:%s\n",hu[a].sex);
printf("籍贯:%s\n",hu[a].jg);
printf("地址:%s\n",hu[a].dz);
printf("QQ:%s\n",hu[a].qq);
printf("电话:%s\n",hu[a].tel);
}
else
printf("无此联系人!!!");
}
[ 本帖最后由 human84 于 2010-1-4 23:43 编辑 ]