CString temp;
this->GetLine(0,temp.GetBuffer(4),4);
MessageBox(temp.GetAt(1),0,MB_OK);<-编译时出问题:
error C2664: 'CWnd::MessageBoxA' : cannot convert parameter 1 from 'ATL::CSimpleStringT<BaseType,t_bMFCDLL>::XCHAR' to 'LPCTSTR'
怎么办啊?

解决方案 »

  1.   

    CString temp;
    this->GetLine(0,temp.GetBuffer(4),4);
             记得temp.ReleaseBuffer() ;
    MessageBox((LPCTSTR)temp,0,MB_OK);<-编译时出问题:
      

  2.   

    char szMessage[2];
    szMessage[0] = temp.GetAt(1);
    szMessage[1] = '\0\';
    MessageBox(temp.GetAt(1),0,MB_OK);
      

  3.   

    GetAt返回的类型和MessageBox的第一个参数类型不一致
      

  4.   

    laiyiling(最熟悉的陌生人):如何解决呢?
    我的目的是从一个CString字符串中读取每个字符,并用messagebox显示出来
      

  5.   

    char szChar[2] = { 0 };
    for( int i = 0; 9 < temp.GetLength( ); i++ )
    {
      szChar[0] = temp[i];
     Messageox( szChar );
    }
      

  6.   

    char szChar[2] = { 0 };
    for( int i = 0; i < temp.GetLength( ); i++ )
    {
      szChar[0] = temp[i];
     Messageox( szChar );
    }
      

  7.   

    TCHAR str;
    str = Temp.GetAt(n);
    MessageBox((LPCTSTR)&str,0,MB_OK);
    应该就没有问题了
      

  8.   

    CString temp;
    temp="ABCD";
    for(int i=0;i<temp.GetLength();i++)
    {
       MessageBox(temp.Mid(i,1),0,MB_OK);
    }
      

  9.   

    说错了一个问题,应该是:
    TCHAR str[2];
    str[0] = Temp.GetAt(n);
    str[1] = '\0';
    MessageBox((LPCTSTR)str,0,MB_OK);
    这里需要一个0终止符
      

  10.   

    老兄,CString.GetAt返回的是个字符呢,如果你需要显示第一个字符,可以用szTemp.Left(1)呀。
      

  11.   

    GetAt返回的是字符,而MessageBox输出的是字符串。
    for(i = 0; i < strTemp1; i++)
    {
        CString     strTemp2(strTemp1.GetAt(i);
        MessageBox(strTemp2);
    }
      

  12.   

    int nLen = temp.GetLength();
    char *pszChar = new char[nLen];lstrcpy(pszChar, temp);...