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