main()
{
int d,a;
printf("Enter the digit :");
scanf("%d",&d);
printf("Enter another digit :");
scanf("%d",&a);
}
输出: 输入数字:10 输入另一个数字:10解释scanf中没有空格和scanf中空白之间有什么区别?
main()
{
int d;
char a[10];
printf("Enter the digit :");
scanf("%d ",&d);
printf("Enter another digit :");
scanf("%s ",a);
}
输出:
Enter the digit : 10
waiting for stdin
任何人都可以解释scanf("%d",&a)
和scanf("%d ",&a)
之间的区别?为什么在scanf
语句中添加空格会导致它等待stdin?
该指令(空格)与输入中的任意数量的空白(包括无)匹配。所以不,你不必输入空格字符。 – timos