fclose
raw OCR
Closes a stream.
Defined in header <stdio.h>
Syntax
#include <stdio.h>
int fclose(FILE *stream);
Portability
| DOS | UNIX | Windows | ANSI C | C++ only |
|---|---|---|---|---|
| ■ | ■ | ■ | ■ |
Remarks
fclose closes the named stream. All buffers associated with the stream are flushed before closing. System-allocated buffers are freed upon closing. Buffers assigned with setbuf or setvbuf are not automatically freed. (But if setvbuf is passed null for the buffer pointer, it will free it upon close.)
Return value
fclose returns 0 on success. It returns EOF if any errors were detected.
See also
Example
#include <string.h>
#include <stdio.h>
int main(void)
FILE *fp;
char buf[ll] = "0123456789";
/* create a file containing 10 bytes */
fp = fopen("DUMMY.FIL", "w");
if (fp) {
fwrite(&buf, strlen(buf), 1, fp) ;
fclose(fp); /* close the file */
}
else
printf("Unable to open file!\n");
return 0;
Differences from modern implementations
Nothing recorded yet.
Modern references
These are search links, not yet checked by hand.
Stable link: /3.1/stdio.h/fclose/
· short form /3.1/fclose/