cmd.Format(_T("segwin.exe -i %s%s.jpg -t 6 -o segResult\\seg\\%s.jpg 0.9 -r9 setResult\\map\\%s.jpg -q 255"),trainingDir,fileName,fileName,fileName);
system(cmd);
错误显示是无法将CString转为 const char *;请各位大侠帮忙啊

解决方案 »

  1.   

    USES_CONVERSION;
    system(T2A(cmd));
      

  2.   

    CString str(_T("..."));
    int* buf = NULL;
    #ifdef _UNICODE
    int len = WideCharToMultiByte(CP_ACP,.., str, -1, buf, 0,...);
    buf = new char[len];
    memset(buf, 0, len);
    WideCharToMultiByte(CP_ACP, ..., str, -1, buf, len, ...);
    #else
    int len = str.GetLength() + 1;
    buf = new char[len];
    memset(buf, 0, len);
    sprintf(buf, "%s", str);
    #endif
    ...
    ...
    delete[] buf;
    buf = NULL;
      

  3.   

    要保证所有的参数一致,要么都是ansi,要么都是unicode。
      

  4.   

    改用这个函数:_tsystem()system(cmd)是多字节版的