macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / stdio / fflush.3
CommitLineData
ae59e04c 1.\" Copyright (c) 1990, 1991 The Regents of the University of California.
48ffd455
KB
2.\" All rights reserved.
3.\"
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
48ffd455
KB
6.\" %sccs.include.redist.man%
7.\"
ae59e04c 8.\" @(#)fflush.3 5.3 (Berkeley) %G%
48ffd455 9.\"
ae59e04c
CL
10.Dd
11.Dt FFLUSH 3
12.Os
13.Sh NAME
14.Nm fflush ,
15.Nm fpurge
16.Nd flush a stream
17.Sh SYNOPSIS
18.Fd #include <stdio.h>
19.Ft int
20.Fn fflush "FILE *stream"
21.Ft int
22.Fn fpurge "FILE *stream"
23.Sh DESCRIPTION
24The function
25.Fn fflush
26forces a write of all buffered data for the given output or update
27.Fa stream
48ffd455 28via the stream's underlying write function.
ae59e04c
CL
29The open status of the stream is unaffected.
30.Pp
48ffd455 31If the
ae59e04c
CL
32.Fa stream
33argument is
34.Dv NULL ,
35.Fn fflush
48ffd455 36flushes
ae59e04c 37.Em all
48ffd455 38open output streams.
ae59e04c
CL
39.Pp
40The function
41.Fn fpurge
48ffd455 42erases any input or output buffered in the given
ae59e04c 43.Fa stream .
48ffd455
KB
44For output streams this discards any unwritten output.
45For input streams this discards any input read from the underlying object
46but not yet obtained via
ae59e04c 47.Xr getc 3 ;
48ffd455 48this includes any text pushed back via
ae59e04c
CL
49.Xr ungetc .
50.Sh RETURN VALUES
48ffd455
KB
51Upon successful completion 0 is returned.
52Otherwise,
ae59e04c 53.Dv EOF
48ffd455 54is returned and the global variable
ae59e04c 55.Va errno
48ffd455 56is set to indicate the error.
ae59e04c
CL
57.Sh ERRORS
58.Bl -tag -width [EBADF]
59.It Bq Er EBADF
60.Fa Stream
48ffd455 61is not an open stream, or, in the case of
ae59e04c 62.Fn fflush ,
48ffd455 63not a stream open for writing.
ae59e04c
CL
64.El
65.Pp
66The function
67.Fn fflush
48ffd455 68may also fail and set
ae59e04c 69.Va errno
48ffd455 70for any of the errors specified for the routine
ae59e04c
CL
71.Xr write 2 .
72.Sh SEE ALSO
73.Xr write 2 ,
74.Xr fopen 3 ,
75.Xr fclose 3 ,
76.Xr setbuf 3
77.Sh STANDARDS
78The
79.Fn fflush
80function
81conforms to
82.St -ansiC .