#include <stdio.h>
int main()
{
char C, B;
int x;
printf("What comes after G\n");
scanf("%c", &C);
printf("What comes after O\n");
scanf("%c", &B);
printf("What is your age?\n");
scanf("%d", &x);
printf("You said %c comes after G, %c after T and you're %d years old? Right?", C, B, x);
return 0;
}
的问题是当你运行该代码会跳过第二个问题:“什么来Ò后”,然后问:“你是什么年龄?”与scanf的问题
我可以可以避免程序跳过第二个问题的唯一途径是通过增加一个空格代码
printf("What comes after O\n");
scanf(" %c", &B);
你可以看到空间
“和 %C之间请问您能解释一下吗?
有同样的问题>看到这里http://stackoverflow.com/questions/12653884/getchar-does-not-stop-when-using-scanf – Oz123