FCLOSE(3)

NAME
fclose, _fclose_r - close a file

SYNOPSIS

#include <stdio.h>

int fclose(FILE *fp);

int _fclose_r(struct _reent *reent, FILE *fp);

DESCRIPTION

If the file or stream identified by fp is open, fclose closes it, after first ensuring that any pending data is written (by calling fflush(fp)).

The alternate function _fclose_r is a reentrant version. The extra argument reent is a pointer to a reentrancy structure.

RETURNS

fclose returns 0 if successful (including when fp is NULL or not an open file); otherwise, it returns EOF.

PORTABILITY

fclose is required by ANSI C.

Required OS subroutines: close, fstat, isatty, lseek, read, sbrk, write.