new stdio; renamed from doscan.c
[unix-history] / usr / src / lib / libc / stdio / fclose.3
CommitLineData
639aed4c
KB
1.\" Copyright (c) 1990 The Regents of the University of California.
2.\" All rights reserved.
22f1f128 3.\"
639aed4c
KB
4.\" This code is derived from software contributed to Berkeley by
5.\" Chris Torek.
6.\"
7.\" %sccs.include.redist.man%
8.\"
9.\" @(#)fclose.3 6.3 (Berkeley) %G%
10.\"
11.TH FCLOSE 3 ""
12.UC 7
22f1f128 13.SH NAME
639aed4c 14fclose \- close a stream
22f1f128 15.SH SYNOPSIS
639aed4c
KB
16.nf
17.ft B
18#include <stdio.h>
19
20int
21fclose(FILE *stream);
22.ft R
23.fi
22f1f128
KM
24.SH DESCRIPTION
25.I Fclose
639aed4c 26dissociates the named
e6ecb2ae 27.I stream
639aed4c
KB
28from its underlying file or set of functions.
29If the stream was being used for output, any buffered data is written
30first, using
31.IR fflush (3).
32Any allocated memory is
33.IR free 'd.
22f1f128 34.SH "SEE ALSO"
639aed4c
KB
35close(2), fflush(3), fopen(3), free(3), setbuf(3)
36.SH "RETURN VALUE"
37Upon successful completion 0 is returned.
38Otherwise,
22f1f128 39.B EOF
639aed4c
KB
40is returned and the global variable
41.I errno
42is set to indicate the error.
43In either case no further access to the stream is possible.
44.SH ERRORS
45.TP 15
46[EBADF]
47.I Stream
48is not an open stream.
49.PP
50.I Fclose
51may also fail and set
52.I errno
53for any of the errors specified for the routines
54.IR close (2)
55or
56.IR fflush (3).
57.SH STANDARDS
58.I Fclose
59conforms to ANSI X3.159-1989 (``ANSI C'').