macro and text revision (-mdoc version 3)
[unix-history] / usr / src / lib / libc / stdio / fclose.3
.\" Copyright (c) 1990, 1991 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.6 (Berkeley) %G%
.\"
.Dd
.Dt FCLOSE 3
.Os
.Sh NAME
.Nm fclose
.Nd close a stream
.Sh SYNOPSIS
.Fd #include <stdio.h>
.Ft int
.Fn fclose "FILE *stream"
.Sh DESCRIPTION
The
.Fn fclose
function
dissociates the named
.Fa stream
from its underlying file or set of functions.
If the stream was being used for output, any buffered data is written
first, using
.Xr fflush 3 .
.Sh RETURN VALUES
Upon successful completion 0 is returned.
Otherwise,
.Dv EOF
is returned and the global variable
.Va errno
is set to indicate the error.
In either case no further access to the stream is possible.
.Sh ERRORS
.Bl -tag -width [EBADF]
.It Bq Er EBADF
The argument
.Fa stream
is not an open stream.
.El
.Pp
The
.Fn fclose
function
may also fail and set
.Va errno
for any of the errors specified for the routines
.Xr close 2
or
.Xr fflush 3 .
.Sh SEE ALSO
.Xr close 2 ,
.Xr fflush 3 ,
.Xr fopen 3 ,
.Xr setbuf 3
.Sh STANDARDS
The
.Fn fclose
function
conforms to
.St -ansiC .