![](/img/trans.png)
[英]Is there any difference between using printf after for-loop and using printf in the for-loop before run break statement?
[英]printf does not run after a loop
我是 c lang 的新手,想写一些简单的程序来练习。 我偶然发现了printf
在循环后无法运行的问题。 我尝试了这个答案中的所有解决方案,但它们在我的情况下不起作用。 我的代码有什么问题,或者我还不知道 c lang 有什么问题吗?
#include <stdio.h>
int main() {
double nc;
for (nc = 0; getchar() != EOF; ++nc)
;
printf("%.0f\n", nc);
return 0;
}
ctrl + z在 Windows 上生成 EOF,在 Linux/Mac 上ctrl + d 。 尝试打破循环。
– 退休忍者
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.