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 and the American National Standards Committee X3, on Information Processing Systems. %%%LICENSE_START(BSD_4_CLAUSE_UCB) Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above c...
NAMEfclose - close a stream
int fclose(FILE *stream);
DESCRIPTIONThe fclose() function flushes the stream pointed to by stream (writing any buffered output data using fflush(3)) and closes the underlying file descriptor.
The behaviour of fclose() is undefined if the stream parameter is an illegal pointer, or is a descriptor already passed to a previous invocation of fclose().
RETURN VALUEUpon successful completion 0 is returned. Otherwise, EOF is returned and errno is set to indicate the error. In either case any further access (including another call to fclose()) to the stream results in undefined behavior.
- The file descriptor underlying stream is not valid.
The fclose() function may also fail and set errno for any of the errors specified for the routines close(2), write(2) or fflush(3).
ATTRIBUTESFor an explanation of the terms used in this section, see attributes(7).