freopen function — Opens a file with an existing stream
FILE* freopen(const char* filename, const char* mode, FILE* stream)
The freopen
function opens
a file using an existing stream. The file previously associated with
the stream
is closed first, and
the named file is opened in the same manner as if fopen
were called. See fopen
for a description of the mode
parameter.
The main purpose of using freopen
is to reopen one of the standard
files: stdin
, stdout
, and stderr
.