内容纲要

[code language=”cpp”]
#ifdef _DEBUG
#ifdef WIN32
#include <windows.h>
#include <stdio.h>
#endif
#endif

int main(int argc, char *argv[])
{

#ifdef _DEBUG
#ifdef WIN32
// detach from the current console window
// if launched from a console window, that will still run waiting for the new console (below) to close
// it is useful to detach from Qt Creator’s <Application output> panel
FreeConsole();

// create a separate new console window
AllocConsole();

// attach the new console to this application’s process
AttachConsole(GetCurrentProcessId());

SetConsoleOutputCP(65001);

// reopen the std I/O streams to redirect I/O to the new console
freopen("CON", "w", stdout);
freopen("CON", "w", stderr);
freopen("CON", "r", stdin);
#endif
#endif
……
[/code]

发表评论

电子邮件地址不会被公开。 必填项已用*标注