【发布时间】:2012-08-22 08:50:15
【问题描述】:
可能重复:
Why does printf not flush after the call unless a newline is in the format string? (in C)
我有这样的代码:
printf("Starting nets allocation...");
while(...)
{
...some operations...
}
puts("DONE");
代码应该立即打印字符串“Starting nets allocation...”,然后在循环之后,应该打印“DONE”。
相反,程序首先执行循环,然后打印字符串“Starting nets allocation...DONE” 为什么会发生?我该如何解决这个问题?
【问题讨论】: