The GNU C Library - Flushing Buffers

Node: Flushing Buffers Next: Controlling Buffering Prev: Buffering Concepts Up: Stream Buffering

Flushing Buffers

Flushing output on a buffered stream means transmitting all accumulated characters to the file. There are many circumstances when buffered output on a stream is flushed automatically:

If you want to flush the buffered output at another time, call fflush , which is declared in the header file `stdio.h'.

Function int fflush (FILE *stream)
This function causes any buffered output on stream to be delivered to the file. If stream is a null pointer, then fflush causes buffered output on all open output streams to be flushed.

This function returns EOF if a write error occurs, or zero otherwise.

Compatibility Note: Some brain-damaged operating systems have been known to be so thoroughly fixated on line-oriented input and output that flushing a line buffered stream causes a newline to be written! Fortunately, this ``feature'' seems to be becoming less common. You do not need to worry about this in the GNU system.


Next: Controlling Buffering Up: Stream Buffering