fclose - close the stream

SYNOPSIS Overview

#include <stdio.h>

int fclose(FILE *stream);

DESCRIPTION Description

Function fclose named stream stream associated with the underlying document or set of functions it is disconnected. If stream has an output, any buffered data is written first, using fflush (. 3).

RETURN VALUE The

Successful implementation returns 0, otherwise it returns EOF and the global variable errno to indicate the error. In either case, convection and then access (including calling again fclose ()) will bring undefined results.

ERRORS

EBADF
stream underlying file descriptor is invalid.

Function fclose may fail and set errno to Close (2), Write (2) or fflush designated (3) value.

NOTES Highlights

Note that fclose only flushes the buffers provided by the C library user space. To ensure that the data is physically stored on disk the kernel buffers must be flushed too. For example, the use of Sync (2) or the fsync (2).  

Guess you like

Origin www.cnblogs.com/fanweisheng/p/11082046.html