为什么scanf卡在while循环中?

use*_*840 4 c

我在while循环中使用了scanf().

while(1)
{
    int input = 0;
    scanf("%d\n", &input);
    printf("%d\n", input);
}
Run Code Online (Sandbox Code Playgroud)

当我运行这个程序,并输入一个数字时,printf()除非我再次输入另一个数字,否则不会显示该数字.为什么?

Vau*_*ato 5

\n您的scanf格式被解释为"空白的任何量".它一直在读取空格(空格,制表符或回车符),直到它碰到不是空格的东西.