xref: /original-bsd/lib/libc/stdio/fflush.3 (revision 4da674f5)
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.

This code is derived from software contributed to Berkeley by
Chris Torek.

%sccs.include.redist.man%

@(#)fflush.3 5.1 (Berkeley) 03/05/91

FFLUSH 3 ""
C 7
NAME
fflush, fpurge - flush a stream
SYNOPSIS
#include <stdio.h>

int
fflush(FILE *stream);

int
fpurge(FILE *stream);
DESCRIPTION
Fflush writes any buffered data for the given output stream via the stream's underlying write function. The stream remains open.

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

Fpurge 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 via getc ; this includes any text pushed back via ungetc .

"RETURN VALUE"
Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the error.
ERRORS

15 [EBADF] Stream is not an open stream, or, in the case of fflush , not a stream open for writing.

Fflush may also fail and set errno for any of the errors specified for the routine write (2).

"SEE ALSO"
write(2), fopen(3), fclose(3), setbuf(3)
STANDARDS
Fflush conforms to ANSI X3.159-1989 (``ANSI C'').