C Language and Libraries Help (clang.hlp) (Table of Contents; Topic list)
fflush
 Summary Example                         Up Contents Index Back
─────Run-Time Library───────────────────────────────────────────────────────
 
     The fflush function flushes a stream.
 
     If the file associated with <stream> is open for output, fflush
     writes the unwritten contents of the buffer either to the
     operating system or to disk. If the file was opened with the "n"
     flag, the buffer associated with the file is written to the
     operating system's buffers. If the file was opened with the "c"
     flag, the buffer associated with the file is written directly to
     disk. Without either flag, the buffer is flushed to the operating
     system.
 
     If the file associated with <stream> is open for input, fflush
     clears the buffer. The fflush function negates the effect of any
     prior call to ungetc against <stream>.
 
     When switching directly between output and input, there must be an
     intervening call to the fflush function or to a file-positioning
     function (fseek, fsetpos, or rewind). Input can be directly
     followed by output without an intervening call to a file-
     positioning function if the input operation encounters end-of-file.
 
     Buffers are automatically flushed to the operating system when
     they are full, when the stream is closed, or when a program
     terminates normally without closing the stream. Also,
     fflush(NULL) flushes all streams opened for output.
 
     The stream remains open after the call. The fflush function has no
     effect on an unbuffered stream.
 
     Return Value
 
     The fflush function returns 0 if the buffer was successfully
     flushed. The value 0 is also returned when the specified stream
     has no buffer or is open for reading only. A return value of EOF
     indicates an error.
 
     NOTE: If fflush returns EOF, data may have been lost because of a
           failed write. When setting up a critical error handler,
           it is safest to turn buffering off with the setvbuf function
           or to use low-level I/O routines such as _open, _close, and
           _write instead of the stream I/O functions.
                                    -♦-