#include <consoleapi.h>
#include <cstdio>
class runtime_consle {
public:
runtime_consle() {
AllocConsole();
freopen("CONOUT$", "w", stdout);
}
~runtime_consle() {
FreeConsole();
fclose(stdout);
}
};
转自:https://blog.csdn.net/weixin_42331112/article/details/106628152