fflush

Flushes the output buffer of a stream.

Library:LibC
Classification:ANSI
Service:File and Directory I/O

Syntax

  #include <stdio.h> 
   
  int fflush (
     FILE   *fp);
  

Parameters

fp

(IN) Points to the file to be flushed.

Return Values

If successful, returns 0. Otherwise, returns nonzero and sets errno to one of the following:

Decimal

Constant

Description

4

EBADF

The file descriptor is not valid.

12

ENOSPC

No free space remains on the device containing the file.

24

EAGAIN

The O_NONBLOCK flag is set for the file descriptor, and the process cannot immediately perform the write operation.

25

ENXIO

A request was made of a nonexistent device, or the request was outside the capabilities of the device.

28

EIO

The process is orphaned and cannot write to the file.

32

EPIPE

An attempt is made to write to a pipe or FIFO that is not open for reading by any process.

63

EINTR

A signal interrupted the fflush function.

71

EFBIG

An attempt was made to write a file that exceeds the maximum file size.

Remarks

If the file pointed to by fp is open for output or update, the fflush function causes any unwritten data to be written to the file.

If the file pointed to by fp is open for input or update, the fflush function undoes the effect of any preceding ungetc operation on the stream.

If the value of fp is NULL, all open files are flushed.

See Also