fclose() function in C | Detail

 fclose() function in C

fclose() function in C

Through this article you will resolve your following doubts which are listed below,

  1. fclose() function in c
  2. header file for fclose() function in c
  3. return value of fclose() function in c
  4. fclose() function in c syntax
  5. fclose() function in c program

fclose() function in C

fclose() function in C is nothing but , it is  also a standard library function of C which is used for closing a file in the memory and after the closing the file the connection between program and file is broken.

Header file for fclose() function in C

fclose() function is define in <stdio.h>/<stdlib.h> which is stand for standard input -output header file and standard library header file respectively.

Return value of fclose function in C

In C, fclose() function returns 0 on success and if fclose( ) function unble to close a file then it return EOF (End of File).

Syntax of fclose( ) function in C

int fclose(file*fptr)

Example of fclose( ) function in C

#include<stdio.h>
#include<stdlib.h>
int main( )
{
FILE *demo;
demo=fopen("demo.txt","w");   
   /* creating a file in memory */
fprintf(demo,"%s","Akash");
fclose(demo);        /* closing a file in memory */
return 0;
}

____________________________________

C fopen() function example
____________________________________
Note:-
This result will not show on your output screen because you write your data into the file so, if you want to see you result/ output then Goto>CDrive>Turbo>Disk>Turbo(version)>Bin and then find your file which you have created earlier and than click on it, Now you will get your output.

Conclusion

fclose( ) function is used for closing a file in the memory.
Post a Comment (0)
Previous Post Next Post