When to use fflush()?

Chris Torek chris at mimsy.UUCP
Wed Aug 30 11:34:21 AEST 1989


In article <143 at sherpa.uucp> rac at sherpa.uucp (Roger A. Cornelius) writes:
>When should you use fflush()? OR are there any guarantees of
>when output buffers are flushed?

Output buffers are flushed by normal program exit (via exit() or
via return from main()), and, in the proposed C standard, by
`fflush((FILE *)NULL);'.  Some output buffers (those that are
`associated with terminals') are flushed by some kinds of input.

The short answer is:  Use fflush() whenever you want the output to
be visible.  Unfortunately, there is no way to simply declare that
all stdio buffers should always be fully buffered; the latter would
help efficiency, and help remind people to use fflush().
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris at mimsy.umd.edu	Path:	uunet!mimsy!chris



More information about the Comp.lang.c mailing list