fopen function(Open File) in C Language – example and detail

In the C Programming Language, the fopen characteristic opens a file known as filename and associates it to stream. The fopen characteristic clears all error and EOF indictors for the stream.


The syntax for the fopen characteristic in the C Language is:

FILE *fopen(const char *filename, const char *mode);

Parameters or Arguments

filename The filename to companion with the new file being opened. mode The mode in which to open the file.


The fopen function returns a file pointer for the new file. If a new file can not be opened, the fopen feature returns a null pointer.

Required Header

In the C Language, the required header for the fopen feature is:

#include <stdio.h>

Applies To

In the C Language, the fopen function can be used in the following versions:

ANSI/ISO 9899-1990

Similar Functions

Other C functions that are similar to the fopen function:

freopen function <stdio.h>

See Also

Other C functions that are noteworthy when dealing with the fopen function:

fclose characteristic setbuf characteristic setvbuf characteristic