CString  lPD="ierudjrhe";
char AccPd[20];for(int i=0;i<lPD.GetLength();i++)
 {
 AccPd[i]=lPD[i];

 }
AccPd[i]='\0';CString  lPD中可能接受别的参数,现在怎么把它去出来进行处理?我上边的程序是做把它赋值到一个字符数组里.但是现在要求直接处理,不再浪费内存.怎么做啊?本人对字符数组比较熟悉,其他不清楚啊在线等

解决方案 »

  1.   

    用CString::GetAt( int nIndex ) 
      

  2.   

    CString strBuf = "1231321321";
    char* pBuf = new char[strBuf.GetLength()];
    pBuf = strBuf.GetBuffer();
    delete pBuf;
      

  3.   


     edison318 :
    char* pBuf = new char[strBuf.GetLength()]; 
    这个和字符数组有区别吗?
    还是要开辟内存,呵呵,不过还是要谢谢啊
      

  4.   

    赋值到字符数组,直接strcpy就行了啊
      

  5.   


    这样的操作有泄漏
    char *pBuf = strBuf.GetBuffer(strBuf.GetLength());
    strBuf.ReleaseBuffer();
      

  6.   

    要用GetBuffer,不要忘记ReleaseBuffer()哦.呵呵
      

  7.   

    TCHAR GetAt( int nIndex ) const
    A TCHAR containing the character at the specified position in the string.for example
    CString s( "abcdef" );
    char d[6];
    for(i=0;i<6;i++)
    {
       d[i]=s.GetAt(i);
    }
      

  8.   

    CString  lPD="ierudjrhe"; 
    char *AccPd; AccPd=(char*)(LPCTSTR)lPD;
    搞定啦,AccPd只是个指向lPD的指针
    *AccPd就是字符,AccPd++就可以移动啦.应该符合老板的意思吧?老板是说直接用,不再赋值到一个字符数组里,开辟内存.还打比方说,有东西放在那儿就直接拿来用,没有必要在先搬
    到别处去再用.谢谢大家啊