学生档案管理问题
这个程序是关于学生档案管理的,有两个功能,查找和修改,这个程序运行没有问题,但是我运行后不能进行修改功能,请高手帮忙下!!
#include <stdio.h>
struct student
{int num;
char name[10];
char sex;
char address[20];
};
struct student stu[3]={ {000,"li lin",'m',"103 beijing road"},
{001,"zhang fun",'m',"130 shanghai road"},
{002,"wang min",'f',"1010 zhongshan road"} } ;
struct student (*p)[3];
void main()
{
void query();
void modify();
char X,Z;
int i;
printf("num name sex address\n");
for (i=0;i<3;i++)
printf("%5d%10s%3c%20s\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].address);
printf("do you want to query?Y OR N\n ");
scanf("%c",&X);
if (X=='Y'||X=='y')
query();
else if (X=='N'||X=='n')
printf("byebye!\n");
printf("do you want to modify?Y or N\n");
scanf("%c",&Z);
if (Z=='Y'||Z=='y')
modify();
else if(Z=='N'||Z=='n')
printf("byebye\n");
}
void query()
{
int i,number;
char Z;
printf("please enter numbers:");
scanf("%d",&number);
printf("num name sex address\n");
for (i=0;i<3;i++ )
{
if (number==stu[i].num)
printf("%3d%20s%2c%20s\n",stu[i].num,stu[i].name,stu[i].sex,stu[i].address);
}
}
void modify()
{
int modinum,k,i;
printf("please input theseat which you will modify:");
scanf("%d",&modinum);
for (i=0;i<3 ;i++ )
{if (modinum==stu[i].num)
{ k=i;
scanf("%d ",&stu[k].num);
scanf("%s",&stu[k].name);
scanf("%c",&stu[k].sex);
scanf("%s",&stu[k].address);}
}
}
附图,在图中的地方就有问题了 !!!