class CConsole
{
public:
CConsole()
{
AllocConsole();
//重定向标准输出
freopen("CONOUT$","w+t",stdout);
//重定向标准输入
freopen("CONIN$","r+t",stdin);
}
~CConsole()
{
fclose(stdout);
fclose(stdin);
FreeConsole();
}
};
//---------------------------------------------------------------------------
CConsole console;
{
public:
CConsole()
{
AllocConsole();
//重定向标准输出
freopen("CONOUT$","w+t",stdout);
//重定向标准输入
freopen("CONIN$","r+t",stdin);
}
~CConsole()
{
fclose(stdout);
fclose(stdin);
FreeConsole();
}
};
//---------------------------------------------------------------------------
CConsole console;