nitin_cherian
nitin_cherian

Reputation: 6675

Buffering Standard Output (STDOUT)

By default, is STDOUT unbuffered? If not what is the type of its default buffering

Thanks

Upvotes: 1

Views: 439

Answers (2)

EnabrenTane
EnabrenTane

Reputation: 7466

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

Upvotes: 1

j_random_hacker
j_random_hacker

Reputation: 51316

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.

Upvotes: 5

Related Questions