RT

解决方案 »

  1.   

    不用设置的, CString对象它会自动增长的,不用你去设置.
      

  2.   

    MSDN中没有查到CString有类似的函数。
    于是,我只想知道CString有没有这样的功能
      

  3.   

    原理类似:class CString
    {
        CString(TCHAR* pX)
       {
           //取长度。
           iLen = strlen(pX);
          m_pData = new TCHAR[iLen];//MS可能不是这种方式。
        
       }
     private:
        TCHAR*  m_pData;//这个用来存储字符指针。
    }
    ------------------------------------------------------这样的结构,还要什么设置缓冲区吗?MS的 cstring是不支持的。
      

  4.   

    CString.GetBufferSetLength();例如:
    LPTSTR pStr = str.GetBufferSetLength(nSize);
    memcpy((void*)pStr,m_lpBufCur,nSize);
      

  5.   

    CString::GetBufferSetLength 
    Return Value
    An LPTSTR pointer to the object’s (null-terminated) character buffer.Parameters
    nNewLength
    The exact size of the CString character buffer in characters.
    CString str;
    LPTSTR pstr = str.GetBufferSetLength(3);
    pstr[0] = 'I';
    pstr[1] = 'c';
    pstr[2] = 'e';// No need for trailing zero or call to ReleaseBuffer()
    // because GetBufferSetLength() set it for us!str += _T(" hockey is best!");//MSDN    CString
      

  6.   

    cstring自动分配内存
    每次存,都会把原来的内存释放掉,开辟一块合适的内存
      

  7.   

    如果对数据库进行操作的话,建议别用CString,用char
    字符串用不好的话,后果很严重的。
      

  8.   

    cstring好像是无限长
    但是如果是trace只有几百字节
      

  9.   

    CString str;
    str.GetBufferSetLength(10000);
    这样就可以了啊
      

  10.   

    一般不用设,可能DEBUG内存较少
      

  11.   

    MFC 有自己的内存池 CPixel什么的
    忘了,反正codeproject上有