[Previous]
[Contents]
[Next]

fclose()

close a file

Synopsis:

#include <stdio.h>
int fclose( FILE *fp );

Description:

The fclose() function closes the file fp. If there's any unwritten buffered data for the file, it's written out before the file is closed. Any unread buffered data is discarded. If the associated buffer was automatically allocated, it's deallocated.

Returns:

0
Success
Nonzero
An error occurred. errno is set to indicate the error.

Examples:

#include <stdio.h>

void main()
  {
    FILE *fp;

    fp = fopen( "stdio.h", "r" );
    if( fp != NULL ) {
      fclose( fp );
    }
  }

Classification:

ANSI

Safety:
Interrupt handler No
Signal handler No
Thread Yes

See also:

errno, fcloseall(), fdopen(), fopen(), freopen(), _fsopen()


[Previous]
[Contents]
[Next]