FFLUSH(3C) | Standard C Library Functions | FFLUSH(3C) |
fflush - flush a stream
#include <stdio.h> int fflush(FILE *stream);
If stream points to an output stream or an update stream in which the most recent operation was not input, fflush() causes any unwritten data for that stream to be written to the file, and the st_ctime and st_mtime fields of the underlying file are marked for update.
If stream points to an input stream or an update stream into which the most recent operation was input, that stream is flushed if it is seekable and is not already at end-of-file. Flushing an input stream discards any buffered input and adjusts the file pointer such that the next input operation accesses the byte after the last one read. A stream is seekable if the underlying file is not a pipe, FIFO, socket, or TTY device.
If stream is a null pointer, fflush() performs this flushing action on all streams for which the behavior is defined above.
An input stream, seekable or non-seekable, can be flushed by explicitly calling fflush() with a non-null argument specifying that stream.
Upon successful completion, fflush() returns 0. Otherwise, it returns EOF and sets errno to indicate the error.
The fflush() function will fail if:
EAGAIN
EBADF
EFBIG
EINTR
EIO
ENOSPC
EPIPE
The fflush() function may fail if:
ENXIO
See attributes(7) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
Interface Stability | Standard |
MT-Level | MT-Safe |
March 25, 2020 | OmniOS |