程序无法输入字符类型数据
#include<stdio.h>
#include<string.h>
struct worker
{
int number;
char name[20];
char sex[4];
int born;
char edu[10];
char duty[20];
int pay;
char addr[15];
int tele;
};
int i=0;
void shuru(struct worker wor[]);
void shuchu(struct worker wor[]);
void chaxun(struct worker wor[]);
void shanchu(struct worker wor[]);
void tianjia(struct worker wor[]);
main()
{
struct worker wor[50];
int a;
do
{
printf("******欢迎进入本系统******\n");
printf("1.输入信息\n2.输出信息\n3.查询信息\n4.添加信息\n5.删除信息\n0.退出\n");
scanf("%d",&a);
switch(a)
{
case 1:shuru(wor);
break;
case 2:shuchu(wor);
break;
case 3:chaxun(wor);
break;
case 4:tianjia(wor);
break;
case 5:shanchu(wor);
break;
case 0:
break;
}
}while(a!=0);
printf("谢谢!\n");
}
void shuru(struct worker wor[])
{
char b;
printf("********请输入职工信息********\n");
do
{
printf("请输入职工号:");
scanf("\n%d",&wor[i].number);
printf("请输入职工姓名:");
scanf("\n%s",wor[i].name);
printf("请输入职工性别:");
scanf("\n%s",wor[i].sex);
printf("请输入职工出生年月:");
scanf("\n%d",&wor[i].born);
printf("请输入职工学历:");
scanf("\n%s",wor[i].edu);
printf("请输入职工职务:");
scanf("\n%s",wor[i].duty);
printf("请输入职工工资:");
scanf("\n%d",&wor[i].pay);
printf("请输入职工地址:");
scanf("\n%s",wor[i].addr);
printf("请输入职工电话:");
scanf("\n%d",&wor[i].tele);
i++;
printf("是否继续\n(Y/N)");
fflush(stdin);
scanf("%c",&b);
}while(b=='Y'||b=='y');
shuchu(wor);
}
void shuchu(struct worker wor[])
{
int k;
for(k=0;k<i;k++)
{
printf("职工号:%d\n",wor[k].number);
printf("姓名:%c\n",wor[k].name);
printf("性别:%c\n",wor[k].sex);
printf("出生年月:%d\n",wor[k].born);
printf("学历:%c\n",wor[k].edu);
printf("职务:%c\n",wor[k].duty);
printf("工资:%d\n",wor[k].pay);
printf("地址:%c\n",wor[k].addr);
printf("电话:%d\n",wor[k].tele);
}
}
void shanchu(struct worker wor[])
{
int x,j,k;
printf("请输入要删除的职工号:");
scanf("%d",&x);
for(j=0;j<i;j++)
{
if(x==wor[j].number)
{
break;
}
}
if(j<i)
{
for(k=j;k<i-1;k++)
{
wor[j]=wor[j+1];
}
printf("删除的职工信息\n");
shuchu(wor);
}
else
{
printf("没有您要删除的职工\n");
shuchu(wor);
}
}
void tianjia(struct worker wor[])
{
printf("请输入职工号:");
scanf("\n%d",&wor[i++].number);
printf("请输入职工姓名:");
scanf("\n%s",wor[i++].name);
printf("请输入职工性别:");
scanf("\n%s",wor[i++].sex);
printf("请输入职工出生年月:");
scanf("\n%d",&wor[i++].born);
printf("请输入职工学历:");
scanf("\n%s",wor[i++].edu);
printf("请输入职工职务:");
scanf("\n%s",wor[i++].duty);
printf("请输入职工工资:");
scanf("\n%d",&wor[i++].pay);
printf("请输入职工地址:");
scanf("\n%s",wor[i++].addr);
printf("请输入职工电话:");
scanf("\n%d",&wor[i++].tele);
}
无法输入字符类型数据,如何解决,谢谢~~~~~~~~