有问题的程序: #1:
int main(void) {
int size;
scanf("%d", &size);
int v[size];
for(int i = 0; i < size; ++i) {
scanf("%d", &v[i]);
printf("the %d-th element is : %d\n",i, v[i]);
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
输出:
5
6 7 8 9 10 11
the 0-th element is : 6
the 1-th element is : 7
the 2-th element is : 8
the 3-th element is : 9
the 4-th element is : 10
Run Code Online (Sandbox Code Playgroud)
我的问题: 为什么程序似乎在您输入后执行了所有打印语句?
那么程序是否会“保留”打印语句以在您按下<Enter>换行符后显示它们?对这种行为有更好的解释吗?