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