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.


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