[Courses] Re: [C] A clarification on fflush(stderr)

Laura Bowser lbowser at andrew.cmu.edu
Thu Aug 8 16:12:05 EST 2002

stderr is *supposed* to be unbuffered according to the ANSI C standard - this
doesn't mean that it is..  In *most* systems, stderr can be flushed by
putting a newline at the end of a printf format string, but if you want to
*guarantee* that you get your output at that time, use fflush.


>On Thu, Aug 08, 2002 at 09:57:53AM -0400, Malcolm-Rannirl wrote:
>> man stdio reads, in part:
>> "When opened, the standard error stream is not fully buffered; the
>> standard input and output streams are fully buffered if and only if the
>> streams do not to refer to an interactive device."
>> Now "not fully buffered" is somewhat unclear and does not seem to mean
>> completely unbuffered, though it might (thus flushing may be appropriate).
>> It's possible it means line buffered (which means fprintf(stderr, "foo\n")
>> would be fine, but fprintf(stderr, ".") would not).
>However, if you read man stderr (if you have the same manpages as I
>do), it says "The stream stderr is unbuffered".

PGP key available at:


Public Key available at 

More information about the Courses mailing list