1FCLOSE(3) Linux Programmer's Manual FCLOSE(3)
2
3
4
6 fclose - close a stream
7
9 #include <stdio.h>
10
11 int fclose(FILE *fp);
12
14 The fclose() function flushes the stream pointed to by fp (writing any
15 buffered output data using fflush(3)) and closes the underlying file
16 descriptor.
17
19 Upon successful completion 0 is returned. Otherwise, EOF is returned
20 and errno is set to indicate the error. In either case any further
21 access (including another call to fclose()) to the stream results in
22 undefined behavior.
23
25 EBADF The file descriptor underlying fp is not valid.
26
27 The fclose() function may also fail and set errno for any of the errors
28 specified for the routines close(2), write(2) or fflush(3).
29
31 C89, C99.
32
34 Note that fclose() only flushes the user-space buffers provided by the
35 C library. To ensure that the data is physically stored on disk the
36 kernel buffers must be flushed too, for example, with sync(2) or
37 fsync(2).
38
40 close(2), fcloseall(3), fflush(3), fopen(3), setbuf(3)
41
43 This page is part of release 3.53 of the Linux man-pages project. A
44 description of the project, and information about reporting bugs, can
45 be found at http://www.kernel.org/doc/man-pages/.
46
47
48
49GNU 2009-02-23 FCLOSE(3)