4.1.2.1 freopen

void freopen(string format, ...)

The freopen action changes the file that is associated with stdout to the file that is specified by the arguments in printf fashion.

If the "" string is used, the output is again restored to stdout.

Caution

The freopen action is not only data-recording but also destructive, because you can use it to overwrite arbitrary files.