Next: , Previous: fopencookie, Up: Stdio


4.19 fpurge—discard pending file I/O

Synopsis

     #include <stdio.h>
     int fpurge(FILE *fp);
     
     int _fpurge_r(struct _reent *reent, FILE *fp);
     

Description
Use fpurge to clear all buffers of the given stream. For output streams, this discards data not yet written to disk. For input streams, this discards any data from ungetc and any data retrieved from disk but not yet read via getc. This is more severe than fflush, and generally is only needed when manually altering the underlying file descriptor of a stream.

The alternate function _fpurge_r is a reentrant version, where the extra argument reent is a pointer to a reentrancy structure, and fp must not be NULL.


Returns
fpurge returns 0 unless fp is not valid, in which case it returns EOF and sets errno.


Portability
These functions are not portable to any standard.

No supporting OS subroutines are required.