请问为啥当 stu[i]=='s'或者't'时,if 语句为何不执行~
#include<stdio.h>struct staff
{
char name[20];
int num;
char sex;
char pro;
union
{
int cla;
char rol[20];
}kind;
}stu[2];
void main()
{
struct staff *p;
p=stu;
int i;
for(i=0;i<2;i++)
{
printf("Please print the name,num,sex and pro :\n");
scanf("%s%d%c%c",&stu[i].name,&stu[i].num,&stu[i].sex,&stu[i].pro);
if(stu[i].pro=='s')
{
printf("please print the class:");
scanf("%d",&stu[i].kind.cla);
printf("%s No.%d Sex:%c pro:%c class No.%d\n",stu[i].name,stu[i].num,stu[i].sex,stu[i].pro,stu[i].kind.cla);
}
if(stu[i].pro=='t')
{
printf("please print the profession:");
scanf("%s",stu[i].kind.rol);
printf("%s No.%d Sex:%c pro:%c class No.%d\n",stu[i].name,stu[i].num,stu[i].sex,stu[i].pro,stu[i].kind.rol);
}
}
}
累觉不爱了已经~~