flush a stream

You're viewing an older version of this page (#3243). View the current version.

View versions (3)

NAME

<span class="Nm" id="fflush">fflush</span>, <span class="Nm" id="fpurge">fpurge</span>

INTERFACE

#include <stdio.h> int fflush ( FILE *stream ) int fpurge ( FILE *stream )

DESCRIPTION

The function fflush forces a write of all buffered data for the given output or update &#92;c stream via the stream's underlying write function. The open status of the stream is unaffected. &#92;n &#92;n If the &#92;c stream argument is <span class="Dv">NULL</span>, fflush flushes <span class="Em">all</span> open output streams. &#92;n &#92;n The function fpurge erases any input or output buffered in the given &#92;c 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 via getc (3) ; this includes any text pushed back via ungetc (3) .

RETURN VALUES

Upon successful completion 0 is returned. Otherwise, <span class="Dv">EOF</span> is returned and the global variable <span class="Va">errno</span> is set to indicate the error.

ERRORS

<table cellspacing="0" class="refpage" style="margin-left:25px"> <tr> <td valign="top" nowrap> [<span class="Bq"><span class="Er">EBADF</span></span>] </td> <td valign="top"> The &#92;c stream argument is not an open stream, or, in the case of fflush , not a stream open for writing. </td> </tr> </table> &#92;n &#92;n The function fflush may also fail and set <span class="Va">errno</span> for any of the errors specified for the routine reference:write (2) .

SEE ALSO

reference:write (2) , fclose (3) , fopen (3) , setbuf (3)

STANDARDS

The fflush function conforms to