可能重複:
Why does printf not flush after the call unless a newline is in the format string? (in C)「printf」 上不打印字符串立刻
我有這樣的代碼:
printf("Starting nets allocation...");
while(...)
{
...some operations...
}
puts("DONE");
代碼應該打印立即顯示字符串「Starting nets allocation ...」,然後在循環之後打印出「DONE」。
相反,該程序首先進行循環,然後打印字符串「啓動網分配...... DONE」 爲什麼會發生?我該如何解決這個問題?
[如何詢問和接受問題](http://stackoverflow.com/faq#howtoask)。 – bitmask