【发布时间】:2017-09-22 20:44:08
【问题描述】:
有人可以在您的 IDE 上运行以下 C 程序并告诉我我缺少什么吗?
#include<stdio.h>
#include<conio.h>
int main()
{
int a;
char s;
char n[10];
printf("What is your name?: ");
scanf("%s", &n);
printf("What is your age?: ");
scanf("%d", &a);
printf("Are you male or female?: ");
scanf("%c", &s);
printf("Your name is %s\nYour age is %d\nYour sex is %c\n", n, a, s);
getch();
return 0;
}
当我们输入年龄并按回车键时,它会滑倒并显示错误的输出,而没有晚上要求第三个输入“你是男性还是女性?”。我在 Turbo C++、Dev C++、Code Blocks 上测试过,都显示相同的错误输出。
【问题讨论】: