I am using this code to redirect stdout but am receiving warnings from MSVC about freopen being unsafe.
freopen( "file.txt", "w", stdout );
The warnings are not uncommon, and having found a thread about the exact warnings I decided to redirect stdout using a "stream redirection guard" as described in the thread. The redirection works for std::cout but not for stdout. This makes sense to me but I'm not sure how to achieve what I want.
So is it possible to get both pointing to the same stream or file?