Does NEWLINE always flush stdio buffer?

Michael Meissner meissner at tiktok.dg.com
Mon Jul 17 00:08:55 AEST 1989


In article <4861 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
| No, it is not. In fact, if (popping down to the implementations I'm familiar
| with) _filbuf(stdin) calls _flsbuf(stdout) you get all the advantages of
| line-buffered output, obviate the need for most explicit fflush() calls, and
| have almost no overhead. This behaviour was first implemented (to my
| knowledge) in the Berkeley stdio library, and is (I believe) what the dpANS
| is referring to.
| 
| In fact, if you implement smart flushing, you can abandon the overhead of
| line buffering completely, without breaking any working programs.

This is not completely true.  I've run into programs, which use stdio
for output, and raw read's for input.  In this case, the output is NOT
flushed.
--
Michael Meissner, Data General.
Uucp:		...!mcnc!rti!xyzzy!meissner		If compiles were much
Internet:	meissner at dg-rtp.DG.COM			faster, when would we
Old Internet:	meissner%dg-rtp.DG.COM at relay.cs.net	have time for netnews?



More information about the Comp.lang.c mailing list