Flush the buffers for a stream
#include <stdio.h>
int fflush( FILE* fp );
- fp
- NULL, or the stream whose buffers you want to flush.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
If the stream specified by fp is open for output or update, the
fflush() function causes any buffered (see
setvbuf())
but unwritten data to be written to the file
descriptor associated with the stream (see
fileno()).
If the file specified by fp is open for input or update, the
fflush() function undoes the effect of any preceding
ungetc operation on the stream.
If fp is NULL, all open streams are flushed.
0 for success, or EOF if an error occurs
(errno is set).
- EAGAIN
- The O_NONBLOCK flag is set for the file descriptor
underlying fp, and the process would be delayed in the
write operation.
- EBADF
- The file descriptor underlying fp isn't valid.
- EFBIG
- One of the following:
- An attempt was made to write a file that exceeds the maximum file size.
- An attempt was made to write a file that exceeds the process's
file size limit.
- The file is a regular file, and an attempt was made to write at or
beyond the offset maximum associated with the corresponding stream.
- EINTR
- The fflust() function was interrupted by a signal.
- EIO
- One of the following:
- The process is a member of a background process group attempting
to write to its controlling terminal, TOSTOP is set,
the process is neither ignoring nor blocking SIGTTOU,
and the process group of the process is orphaned.
- (QNX Neutrino extension) An I/O error occurred when writing cached
data to the underlying media.
- (QNX Neutrino extension) An I/O error occurred when updating metadata
on the underlying media.
- (QNX Neutrino extension) The filesystem resides on a removable media
device, and the media has been forcibly removed.
- ENOSPC
- There was no free space remaining on the device containing the file.
- ENXIO
- A request was made of a nonexistent device, or the request was outside
the capabilities of the device.
- EPIPE
- An attempt was made to write to a pipe or FIFO that wasn't open for
reading by any process.
A SIGPIPE signal is also sent to the thread.
#include <stdio.h>
#include <stdlib.h>
int main( void )
{
printf( "Press Enter to continue..." );
fflush( stdout );
getchar();
return EXIT_SUCCESS;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
Yes |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
errno,
fgetc(),
fgets(),
fileno(),
flushall(),
fopen(),
getc(),
gets(),
setbuf(),
setvbuf(),
ungetc()