在应用程序的入口调用以下函数.
#include "io.h"
#include "fcntl.h"
void CreateConsole()
{
int nRet= 0;
FILE* fp;
//
AllocConsole();
nRet = _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
fp = _fdopen(nRet, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
}