C stdio fopen() Function
Example
Create a file:
FILE *fptr;
// Create a file
fptr = fopen("filename.txt", "w");
// Close the file
fclose(fptr);
Try it Yourself »
Definition and Usage
The fopen()
function opens a file and returns a special FILE
pointer which is used in other functions that read and write into files.
The fopen()
function is defined in the <stdio.h>
header file.
Syntax
fopen(const char * filename, const char * mode);
Parameter Values
Parameter | Description |
---|---|
filename | Required. A string containing the path to the file. |
mode |
Required. A string describing how the file will be used. It can be one of the following
r+b .
|
Technical Details
Returns: | A FILE pointer which can be used by other file handling functions. |
---|