Table of Content

stdio.h >> fclose function

What it does ?
  • Closes a stream
Declaration:  int fclose(FILE *stream);


  1. fclose closes the named stream.All buffers associated with the stream are flushed before closing.
  2. System-allocated buffers are freed upon closing.
  3. 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

  ■ On success, returns 0
  ■ On error, returns EOF


int main(void)
FILE *fp;
char buf[11] = "0123456789";

/* create a file containing 10 bytes */
fp = fopen("temp.FIL", "w");
fwrite(&buf, strlen(buf), 1, fp);

/* close the file */
return 0;

Bookmark & Share