Journey to C
Buffering
Characters that are written to a stream are normally accumulated and transmitted asynchronously to the file in a block, instead of appearing as soon as they are output by the application program. Flushing output on a buffered stream means transmitting all accumulated characters. There are many circumstances when buffered output on a stream is flushed automatically:
- When you try to do output and the output buffer is full.
- When the stream is closed.
- When the program terminates by calling
exit
. - When a newline is written, if the stream is line buffered.
If you want to flush the buffered output at another time, call fflush
, which is declared in the header file stdio.h.
LINKS