12.20.2 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 automati-
cally:
• When you try to do output and the output buffer is full.
• When the stream is closed. See Section 12.4 [Closing Streams], page 259.
• When the program terminates by calling exit. See Section 25.7.1 [Normal Termina-
tion], page 759.
• When a newline is written, if the stream is line buffered.
• Whenever an input operation on any stream actually reads data from its file.
If you want to flush the buffered output at another time, call fflush, which is declared
in the header file stdio.h.
int fflush ( FILE *stream )
[Function]
Preliminary: | MT-Safe | AS-Unsafe corrupt | AC-Unsafe lock corrupt | See
Section 1.2.2.1 [POSIX Safety Concepts], page 2.
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.
Partager