Is it possible (and if so, how?) to redirect stdout (and, optionally, stderr) temporarily to a file, and later recover the original stdout?
In a POSIX environment, I use dup and dup2 to store and replace STDOUT_FILENO. freopen isn't a good solution, since stdout cannot be recovered that way.
Is it possible to do this with the Windows API? I believe it is possible using the POSIX-like functions _DUP and _DUP2. Is there a solution that doesn't involve them?