When to use fflush()?
Doug Gwyn
gwyn at smoke.BRL.MIL
Thu Aug 31 07:46:23 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?
Use fflush() whenever you want to make sure that the buffers are forced out.
>I have a program that uses fputs() to print a prompt, then waits for a
>return to be typed. The prompt is always displayed, but am I guaranteed
>of this?
Recent versions of stdio attempt to force out all output possibly associated
with a "terminal" whenever input is requested from a "terminal". It is not
always possible to tell what is really a terminal, though. Modern stdio
also defaults to line-buffered output on "terminals", although that wouldn't
help for a prompt on the same line as the input.
>Should I use fflush() anyway? What's the rule for when to use
>fflush(), and when it's not needed?
See my first sentence.
More information about the Comp.lang.c
mailing list