代码如下,看似无误
char *ss=strLine.GetBufferSetLength(strLine.GetLength()); //出错
char *p;
CStringArray strArrRes;
for ( p=strtok(ss, " "); p!=NULL; p=strtok(NULL, " ") )
{
strArrRes.Add(p);
}error C2440: 'initializing' : cannot convert from 'unsigned short *' to 'char *'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.
若是将出错行改为unsigned short ……,错误还是会移到下面的for语句,
因为strtok中的ss要求是char* :(,无能为力,只好求助大家

解决方案 »

  1.   

    LPTSTR CString::GetBufferSetLength( int nNewLength );
      

  2.   

    如果只是转一下你用sprintf(ss,"%s",strLine);
      

  3.   

    或ss = (LPSTR)(LPCTSTR)strLine;
      

  4.   

    运用nineclock(本人成分:59%的帅,40%的酷,1%的微量羞涩(-'_'-))的方法
    编译通过
    而运行在for ( p=strtok(ss, " "); p!=NULL; p=strtok(NULL, " ") )处中止
    我用的是unicode方式
      

  5.   

    Unhandl exception in calss.exe(MSVCRTD.DLL):0xC0000005:Access Violation
    调试错误指向了strtok.c