freopen
From cppreference.com
Defined in header
<stdio.h>
|
||
(until C99) | ||
(since C99) | ||
Reassigns an existing file stream stream
to a different file identified by filename
using specified mode. mode
is used to determine the new file access mode.
Contents |
[edit] Parameters
filename | - | file name to associate the file stream to | |||||||||||||||||||||||||||||||||||||||||||||
mode | - | null-terminated character string determining new file access mode
|
|||||||||||||||||||||||||||||||||||||||||||||
stream | - | the file stream to modify |
[edit] Return value
stream
on success, NULL on failure
[edit] Example
The following code redirects stdout
to a file
Run this code
Output:
stdout is printed to console
[edit] See also
opens a file (function) |
|
closes a file (function) |
|
C++ documentation for freopen
|