CString show = "your";
char *Str = show.GetBuffer(show.GetLength());
show.ReleaseBuffer();

解决方案 »

  1.   

    会出现error C2440: 'initializing' : cannot convert from 'unsigned short *' to 'char *'的错误。为什么?
      

  2.   

    CString csStr1= "teststr"char *sStr = csStr1.GetBuffer(0);CString csStr2 ;csStr2 = sStr;
    csStr2 = _T(sStr);   //都可以
      

  3.   

    CString 与 const char * 可以随便赋值
      

  4.   

    CString str="I am a boy";
    const char* pch;
    pch=LPCTCSTR(str);
      

  5.   

    exp1:
      CString s;
      char ss[40];
      wsprintf(ss,"%s",s);exp2:
      CString s;
      char ss[40];
      s.Format("%s",ss);
      

  6.   

    消息提示错误error C2440: 'initializing' : cannot convert from 'unsigned short *' to 'char *'
    不知道是什么原因?是不是有些头文件没有包括?
      

  7.   

    用wsprintf 和CString ::Format不是很简单吗?
      

  8.   

    CString str;
    char ch;
    CString ==》 char
    CString.SetAr(...)
    char ==> CString
    str.Format("%c",ch);
    sprintf(str,"%c",ch);
    装上MSDN,上面什么说明都有!:)
      

  9.   

    上面的第四行写错了应该是:
    str.SetAt(n);n为字串中的第几个字符!
      

  10.   

    crazy_wxf():我编译了一下,出现一下错误:
    error C2664: 'wsprintfW' : cannot convert parameter 1 from 'char [10]' to 'unsigned short *'
      

  11.   

    1.    CString strT("theString");
    2.    char* p_szS = new char [strT.GetLength() +1];
    3.    strcpy(p_szS,(LPCSTR)strT);1.    char szSS[] = "theString";
    2.    CString strT;
    3.    strT.Format("%s",szSS);