no SCCS file; new copyright; att/bsd/shared
[unix-history] / usr / src / lib / libc / stdio / fflush.3
CommitLineData
48ffd455
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\" @(#)fflush.3 5.1 (Berkeley) %G%
10.\"
11.TH FFLUSH 3 ""
12.UC 7
13.SH NAME
14fflush, fpurge \- flush a stream
15.SH SYNOPSIS
16.nf
17.ft B
18#include <stdio.h>
19
20int
21fflush(FILE *stream);
22
23int
24fpurge(FILE *stream);
25.ft R
26.fi
27.SH DESCRIPTION
28.I Fflush
29writes any buffered data for the given output
30.I stream
31via the stream's underlying write function.
32The stream remains open.
33.PP
34If the
35.I stream
36argument is NULL,
37.I fflush
38flushes
39.I all
40open output streams.
41.PP
42.I Fpurge
43erases any input or output buffered in the given
44.IR stream .
45For output streams this discards any unwritten output.
46For input streams this discards any input read from the underlying object
47but not yet obtained via
48.IR getc ;
49this includes any text pushed back via
50.IR ungetc .
51.SH "RETURN VALUE"
52Upon successful completion 0 is returned.
53Otherwise,
54.B EOF
55is returned and the global variable
56.I errno
57is set to indicate the error.
58.SH ERRORS
59.TP 15
60[EBADF]
61.I Stream
62is not an open stream, or, in the case of
63.IR fflush ,
64not a stream open for writing.
65.PP
66.I Fflush
67may also fail and set
68.I errno
69for any of the errors specified for the routine
70.IR write (2).
71.SH "SEE ALSO"
72write(2), fopen(3), fclose(3), setbuf(3)
73.SH STANDARDS
74.I Fflush
75conforms to ANSI X3.159-1989 (``ANSI C'').