操StackOverflow,操OpenAI。
这应该可行,但我没有测试它:
void RedirectIOConsole() { freopen("CONIN$", "r", stdin); freopen("CONOUT$", "w", stdout); freopen("CONERR$", "w", stderr); }
您应该使用
stdout = fp;
*stdout = *fp