Standard Library Functions in C

adplus-dvertising
fclose() Function
Previous Home Next

Description

The C library function, The fclose() function closes the stream that was opened by a call to fopen( ). we perform appropriate operations on file and when file is no longer needed then we close the file. File close will flush out all the entries from buffer.

Declaration

Following is the declaration for fclose() function.

int fclose(FILE *stream)

Parameters

stream - where stream is the file pointer returned by the call to fopen( ).

Return Value

Areturn value of zero signifies a successful close operation. The function returns EOF if an error occurs

Example

#include <stdio.h>

int main()
{
   FILE *fp;
 
   fp = fopen("content.txt", "w");

   fprintf(fp, "%s", "This is Ram");
   fclose(fp);
   
   return(0);
}

Output

This is Ram
Previous Home Next