#include<iostream>
using namespace std;
//在某一个对话框函数里,用的unicode
AllocConsole();
setlocale( LC_ALL, "chs" );
for(int i=0;i<(m_routeData.size());i++)
{
wcout<<m_routeData[i].gmc_id<<m_routeData[i].lmc_id<<m_routeData[i].ms_id<<m_routeData[i].str<<L'\n';
}
之后使用WriteConsole进行输出:
WriteConsole
The WriteConsole function writes a character string to a console screen buffer beginning at the current cursor location. BOOL WriteConsole(
HANDLE hConsoleOutput, // handle to screen buffer
CONST VOID *lpBuffer, // write buffer
DWORD nNumberOfCharsToWrite, // number of characters to write
LPDWORD lpNumberOfCharsWritten, // number of characters written
LPVOID lpReserved // reserved
);
VOID InitConsole()
{
int nRet= 0;
FILE* fp;
if (AttachConsole(ATTACH_PARENT_PROCESS))
{
}
else
{
AllocConsole();
}
nRet= _open_osfhandle((long)GetStdHandle(STD_OUTPUT_HANDLE), _O_TEXT);
fp = _fdopen(nRet, "w");
*stdout = *fp;
setvbuf(stdout, NULL, _IONBF, 0);
}InitConsole();
setlocale(LC_ALL, "");