xref: /original-bsd/lib/libc/stdio/fclose.3 (revision 9d1db70c)
Copyright (c) 1990 The Regents of the University of California.
All rights reserved.

This code is derived from software contributed to Berkeley by
Chris Torek.

%sccs.include.redist.man%

@(#)fclose.3 6.3 (Berkeley) 01/20/91

FCLOSE 3 ""
C 7
NAME
fclose - close a stream
SYNOPSIS
#include <stdio.h>

int
fclose(FILE *stream);
DESCRIPTION
Fclose dissociates the named stream from its underlying file or set of functions. If the stream was being used for output, any buffered data is written first, using fflush (3). Any allocated memory is free 'd.
"SEE ALSO"
close(2), fflush(3), fopen(3), free(3), setbuf(3)
"RETURN VALUE"
Upon successful completion 0 is returned. Otherwise, EOF is returned and the global variable errno is set to indicate the error. In either case no further access to the stream is possible.
ERRORS

15 [EBADF] Stream is not an open stream.

Fclose may also fail and set errno for any of the errors specified for the routines close (2) or fflush (3).

STANDARDS
Fclose conforms to ANSI X3.159-1989 (``ANSI C'').