fopen() function in C | Detail

fopen() function in C

fopen() function in c
fopen() function

Through this article you will resolve your following doubt which is listed below,

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

fopen() function in C

fopen() function in C is nothing but , it is a standard library function of C which is  used for open a file in stream for use and link a file with that stream.

Header file for fopen() function in C

fopen() function is define in <stdio.h> which is stand for standard input and output. 

Return value of fopen function in C

In C fopen() function returns a pointer of type FILE on success and returns NULL, and return value of fopen() function is assigned to a FILE pointer.

Syntax of fopen( ) function in C

FILE *fopen()(" const char *file name", const char " mode");
or
*file_name=fopen("const char *file_name",const char " mode");


Example of fopen( ) 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);
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

fopen( ) function is used for creating a file in the memory.

Post a Comment (0)
Previous Post Next Post