如何关闭标准输出的缓冲用C [英] How to turn off buffering of stdout in C
本文介绍了如何关闭标准输出的缓冲用C的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要关闭的标准输出缓冲获取确切的结果以下code
I want to turn off the buffering for the stdout for getting the exact result for the following code
while(1) {
printf(".");
sleep(1);
}
的code printf的一堆'。只有当缓冲区被填满。
The code printf bunch of '.' only when buffer gets filled.
推荐答案
使用 fflush(标准输出)
。你可以调用后它的每的printf
来强制缓存刷新。
Use fflush(stdout)
. You can call it after every printf
to force the buffer to flush.
这篇关于如何关闭标准输出的缓冲用C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文