fclose function


fclose is used to close a file.

Library:   stdio.h

Prototype: int fclose( FILE *stream);

Syntax:    FILE *fp;
	   fclose(fp);

Note: fclose does not modify fp in a way that indicates that the file is, in fact, closed. So if you may get multiple commands which will close the file, you must set fp to null manually after closing the file, and before trying to close it, test that fp is not null. e.g.

if (fd != NULL) {
    fclose(fd);
    fd = NULL;
    }
example program.


See Also:


Top Master Index Keywords Functions


Martin Leslie