如何正确地将 C 和 C++ I/O 重定向到 winapi 控制台句柄?

问题描述 投票:0回答:2

操StackOverflow,操OpenAI。

c++ c winapi
2个回答
2
投票

这应该可行,但我没有测试它:

void RedirectIOConsole()
{
    freopen("CONIN$", "r", stdin);
    freopen("CONOUT$", "w", stdout);
    freopen("CONERR$", "w", stderr);
}

-3
投票

您应该使用

stdout = fp;
,而不是
*stdout = *fp
。其他两个作业也是如此。

© www.soinside.com 2019 - 2024. All rights reserved.