Commit | Line | Data |
---|---|---|
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 | |
24 | The function | |
25 | .Fn fflush | |
26 | forces a write of all buffered data for the given output or update | |
27 | .Fa stream | |
48ffd455 | 28 | via the stream's underlying write function. |
ae59e04c CL |
29 | The open status of the stream is unaffected. |
30 | .Pp | |
48ffd455 | 31 | If the |
ae59e04c CL |
32 | .Fa stream |
33 | argument is | |
34 | .Dv NULL , | |
35 | .Fn fflush | |
48ffd455 | 36 | flushes |
ae59e04c | 37 | .Em all |
48ffd455 | 38 | open output streams. |
ae59e04c CL |
39 | .Pp |
40 | The function | |
41 | .Fn fpurge | |
48ffd455 | 42 | erases any input or output buffered in the given |
ae59e04c | 43 | .Fa stream . |
48ffd455 KB |
44 | For output streams this discards any unwritten output. |
45 | For input streams this discards any input read from the underlying object | |
46 | but not yet obtained via | |
ae59e04c | 47 | .Xr getc 3 ; |
48ffd455 | 48 | this includes any text pushed back via |
ae59e04c CL |
49 | .Xr ungetc . |
50 | .Sh RETURN VALUES | |
48ffd455 KB |
51 | Upon successful completion 0 is returned. |
52 | Otherwise, | |
ae59e04c | 53 | .Dv EOF |
48ffd455 | 54 | is returned and the global variable |
ae59e04c | 55 | .Va errno |
48ffd455 | 56 | is set to indicate the error. |
ae59e04c CL |
57 | .Sh ERRORS |
58 | .Bl -tag -width [EBADF] | |
59 | .It Bq Er EBADF | |
60 | .Fa Stream | |
48ffd455 | 61 | is not an open stream, or, in the case of |
ae59e04c | 62 | .Fn fflush , |
48ffd455 | 63 | not a stream open for writing. |
ae59e04c CL |
64 | .El |
65 | .Pp | |
66 | The function | |
67 | .Fn fflush | |
48ffd455 | 68 | may also fail and set |
ae59e04c | 69 | .Va errno |
48ffd455 | 70 | for 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 | |
78 | The | |
79 | .Fn fflush | |
80 | function | |
81 | conforms to | |
82 | .St -ansiC . |