Guardian C Library Calls Reference Manual
fclose
3-34 128833—Guardian TNS C Library Calls Reference Manual
Reference to Library Calls
fclose
The fclose function closes a file opened for ANSI I/O and writes any data in the buffer
to the file.
stream
denotes a file opened for ANSI I/O.
Return Value
is zero if the operation is successful or the value EOF if an error occurs.
Usage Guidelines
•
If the file was written to, fclose writes any data in the buffer to the file.
•
Whenever a program calls the exit function or returns from main, C automatically
closes all open files. You should, however, close all files explicitly by calling fclose
or fcloseall.
Example
This example closes the file $a.b.c:
#include <stdioh>
int main(void)
{
FILE *fp;
int status;
fp = fopen("$a.b.c", "w");
/* ... */
status = fclose(fp);
if(status==EOF) printf("fclose function failed\n");
}
#include <stdioh>
int fclose(FILE *stream);