Redirecting stdout in win32 does not redirect stdout
问题 I'm trying to redirect stdout so that printf in a windows application will go to a file of my choice. I'm doing this: outFile = fopen("log.txt", "w"); *stdout = *outFile; setvbuf(stdout, NULL, _IONBF, 0); but printf still writes to the console (or nowhere on a GUI based win32 application) I can redirect 'std::cout' by doing this: outFileStr = std::ofstream(outFile); std::cout.rdbuf(outFileStr.rdbuf()); But printf seems to be doing its own thing. Unfortunately, I need to redirect printf as I'm