分割CString类型的字符串

int SplitString(const CString str, char split, CStringArray &strArray)  
{  
    strArray.RemoveAll();  
    CString strTemp = str;  
    int iIndex = 0;  
    while (1)  
    {  
        iIndex = strTemp.Find(split);  
        if(iIndex >= 0)  
        {  
            strArray.Add(strTemp.Left(iIndex));  
            strTemp = strTemp.Right(strTemp.GetLength()-iIndex-1);  
        }  
        else  
        {  
            break;  
        }  
    }  
    strArray.Add(strTemp);  
  
    return strArray.GetSize();  
} 

 

posted @ 2017-10-25 14:12  zero_to_infinity  阅读(2127)  评论(0编辑  收藏  举报