c++ 重定位输出到DOS

#define USE_WIN32_CONSOLE

int APIENTRY _tWinMain(HINSTANCE hInstance,
                       HINSTANCE hPrevInstance,
                       LPTSTR    lpCmdLine,
                       int       nCmdShow)
{
    UNREFERENCED_PARAMETER(hPrevInstance);
    UNREFERENCED_PARAMETER(lpCmdLine);

#ifdef USE_WIN32_CONSOLE
	AllocConsole();
	freopen("CONIN$", "r", stdin);
	freopen("CONOUT$", "w", stdout);
	freopen("CONOUT$", "w", stderr);
#endif





#ifdef USE_WIN32_CONSOLE
	FreeConsole();
#endif

}

  

posted @ 2016-09-03 18:53  冷夜 - 网游编程技术  阅读(547)  评论(0编辑  收藏  举报