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 will flush the stream pointed to by fp (writing
15 any buffered output data using fflush(3)) and close the underlying file
16 descriptor.
17
19 Upon successful completion 0 is returned. Otherwise, EOF is returned
20 and the global variable errno is set to indicate the error. In either
21 case any further access (including another call to fclose()) to the
22 stream results in undefined behaviour.
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 Note that fclose() only flushes the user space buffers provided by the
32 C library. To ensure that the data is physically stored on disk the
33 kernel buffers must be flushed too, e.g. with sync(2) or fsync(2).
34
36 C89, C99.
37
39 close(2), fcloseall(3), fflush(3), fopen(3), setbuf(3)
40
41
42
43BSD MANPAGE 1993-11-29 FCLOSE(3)