fflush()

NAME

fflush(), fpurge() - flush a stream

SYNOPSIS

#include <stdio.h>

int fflush (FILE *stream) int fpurge (FILE *stream)

DESCRIPTION

The function fflush(3) forces a write of all buffered data for the given output or update stream through the stream's underlying write function. The open status of the stream is unaffected.

If the stream argument is NULL, fflush(3) flushes all open output streams.

The function fpurge(3) erases any input or output buffered in the given stream. For output streams this discards any unwritten output. For input streams, this discards any input read from the underlying object but not yet obtained through getc(3); this includes any text pushed back through ungetc(3).

RETURN VALUES

Upon successful completion the functions return 0. Otherwise, they return EOF and set the global variable errno to indicate the error.

ERRORS

[EBADF]
Stream is not a stream open for writing.

Fflush(3) can also fail for any of the reasons associated with the write(2) function.

SEE ALSO

fclose(3)

fopen(3)

setbuf(3)

write(2)