Commit | Line | Data |
---|---|---|
639aed4c KB |
1 | .\" Copyright (c) 1990 The Regents of the University of California. |
2 | .\" All rights reserved. | |
22f1f128 | 3 | .\" |
639aed4c KB |
4 | .\" This code is derived from software contributed to Berkeley by |
5 | .\" Chris Torek. | |
6 | .\" | |
7 | .\" %sccs.include.redist.man% | |
8 | .\" | |
9 | .\" @(#)fclose.3 6.3 (Berkeley) %G% | |
10 | .\" | |
11 | .TH FCLOSE 3 "" | |
12 | .UC 7 | |
22f1f128 | 13 | .SH NAME |
639aed4c | 14 | fclose \- close a stream |
22f1f128 | 15 | .SH SYNOPSIS |
639aed4c KB |
16 | .nf |
17 | .ft B | |
18 | #include <stdio.h> | |
19 | ||
20 | int | |
21 | fclose(FILE *stream); | |
22 | .ft R | |
23 | .fi | |
22f1f128 KM |
24 | .SH DESCRIPTION |
25 | .I Fclose | |
639aed4c | 26 | dissociates the named |
e6ecb2ae | 27 | .I stream |
639aed4c KB |
28 | from its underlying file or set of functions. |
29 | If the stream was being used for output, any buffered data is written | |
30 | first, using | |
31 | .IR fflush (3). | |
32 | Any allocated memory is | |
33 | .IR free 'd. | |
22f1f128 | 34 | .SH "SEE ALSO" |
639aed4c KB |
35 | close(2), fflush(3), fopen(3), free(3), setbuf(3) |
36 | .SH "RETURN VALUE" | |
37 | Upon successful completion 0 is returned. | |
38 | Otherwise, | |
22f1f128 | 39 | .B EOF |
639aed4c KB |
40 | is returned and the global variable |
41 | .I errno | |
42 | is set to indicate the error. | |
43 | In either case no further access to the stream is possible. | |
44 | .SH ERRORS | |
45 | .TP 15 | |
46 | [EBADF] | |
47 | .I Stream | |
48 | is not an open stream. | |
49 | .PP | |
50 | .I Fclose | |
51 | may also fail and set | |
52 | .I errno | |
53 | for any of the errors specified for the routines | |
54 | .IR close (2) | |
55 | or | |
56 | .IR fflush (3). | |
57 | .SH STANDARDS | |
58 | .I Fclose | |
59 | conforms to ANSI X3.159-1989 (``ANSI C''). |