C Language: freopen function
(Reopen File)
In the C Programming Language, the freopen function first closes the file associated with stream. Then the freopen function opens filename and associates it with stream. In essence, it associates a different file to a stream that is already open.
Syntax
The syntax for the fopen function in the C Language is:
FILE *freopen(const char *filename, const char *mode, FILE *stream);
Parameters or Arguments
- filename
- The filename to associate with the file being reopened.
- mode
- The mode in which to open the file.
- stream
- The stream to associate with filename.
Returns
The freopen function returns a file pointer for the opened file. If the file can not be opened, the freopen function returns a null pointer.
Required Header
In the C Language, the required header for the freopen function is:
#include <stdio.h>
Applies To
In the C Language, the freopen function can be used in the following versions:
- ANSI/ISO 9899-1990
Similar Functions
Other C functions that are similar to the freopen function:
See Also
Other C functions that are noteworthy when dealing with the freopen function:
Advertisements