Next Previous Contents

34. fclose

Synopsis

Close a file

Usage

Integer_Type fclose (File_Type fp)

Description

The fclose function may be used to close an open file pointer fp. Upon success it returns zero, and upon failure it sets errno and returns -1. Failure usually indicates a that the file system is full or that fp does not refer to an open file.

Notes

Many C programmers call fclose without checking the return value. The S-lang language requires the programmer to explicitly handle any value returned by a S-lang function. The simplest way to handle the return value from fclose is to use it as:

     () = fclose (fp);
See Also

fopen, fgets, fflush, errno


Next Previous Contents