开发者

Buffering Standard Output (STDOUT)

开发者 https://www.devze.com 2023-02-01 07:45 出处:网络
By default, is STDOUT unbuffered? If no开发者_运维技巧t what is the type of its default buffering

By default, is STDOUT unbuffered? If no开发者_运维技巧t what is the type of its default buffering

Thanks


You didn't give a language, but assuming that you're using C's stdio functions (fopen() etc.) or a language that uses these (and most do, for portability reasons):

It depends on the underlying C runtime library.

Most libraries will try to detect whether STDOUT is connected to a terminal, and avoid buffering if so, and perform block buffering (e.g. my Linux system buffers 8Kb at a time) if not.


Short Answer: By default STDOUT is usually unbuffered. If this is a problem for you, there is fflush(stdout); but that is rarely needed

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号