去掉字符串空格

来源:互联网 发布:27世纪人工智能系统gif 编辑:程序博客网 时间:2024/05/17 05:17
CString str= "sd  oityo   dfg";

str.Remove(' ');

//最简单的方式


void TrimAll(char *pszBuf)
{
  int nLen = strlen(pszBuf);
  char *pTemp = new char[nLen * sizeof(char)];
  
  for(int i=0,int j=0; i<nlen; i++)
    if( pszBuf[i] != char(0x20) )
    {
        pTemp[j++] = pszBuf[i];
    }
  
  strcpy(pszBuf,pTemp);
  delete pTemp;
  
}

原创粉丝点击