1.\" Copyright (c) 1990, 1991 The Regents of the University of California. 2.\" All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" Chris Torek. 6.\" %sccs.include.redist.man% 7.\" 8.\" @(#)fclose.3 6.6 (Berkeley) 04/19/91 9.\" 10.Dd 11.Dt FCLOSE 3 12.Os 13.Sh NAME 14.Nm fclose 15.Nd close a stream 16.Sh SYNOPSIS 17.Fd #include <stdio.h> 18.Ft int 19.Fn fclose "FILE *stream" 20.Sh DESCRIPTION 21The 22.Fn fclose 23function 24dissociates the named 25.Fa stream 26from its underlying file or set of functions. 27If the stream was being used for output, any buffered data is written 28first, using 29.Xr fflush 3 . 30.Sh RETURN VALUES 31Upon successful completion 0 is returned. 32Otherwise, 33.Dv EOF 34is returned and the global variable 35.Va errno 36is set to indicate the error. 37In either case no further access to the stream is possible. 38.Sh ERRORS 39.Bl -tag -width [EBADF] 40.It Bq Er EBADF 41The argument 42.Fa stream 43is not an open stream. 44.El 45.Pp 46The 47.Fn fclose 48function 49may also fail and set 50.Va errno 51for any of the errors specified for the routines 52.Xr close 2 53or 54.Xr fflush 3 . 55.Sh SEE ALSO 56.Xr close 2 , 57.Xr fflush 3 , 58.Xr fopen 3 , 59.Xr setbuf 3 60.Sh STANDARDS 61The 62.Fn fclose 63function 64conforms to 65.St -ansiC . 66