#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';
}

解决方案 »

  1.   

    检查一下AllocConsole的返回值,看看执行成功没?
    之后使用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
    );
      

  2.   

    http://blog.csdn.net/huiyouyongdeyu2011/article/details/6556168
      

  3.   

    之前,想过用WriteConsole//但是我是双字节的怎么办呢 双字节用不了吧
      

  4.   

    //我以前用这 记得可以成功,你试试。
    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, "");