我写了一个简单的程序,输入字母,输出相应的Ascii码,或输入Ascii码,输出相应的字母。编译正确
运行时,当我选1,然后回车,系统就把我输的回车当作是b了好像.请大家帮我纠正一下,谢谢诶
main()
{ int a,i;
char b;
printf("1:letter into Ascii number.\n");
printf("2:Ascii number into letter.\n");
scanf("%d",&i);
if(i==1)
{
printf("please input your letter:\n");
scanf("%c",&b);
a=b;
printf("letter:%c ",b);
printf("Ascii:%d",a);
}
else
{
printf("input you Ascii number:\n");
scanf("%d",&a);
b=a;
printf("Ascii:%d ",a);
printf("letter:%c",b);
}
getch();
}