|
发表于 2018-7-25 10:22:41
|
显示全部楼层
如果是 CString 进行分割的话,我手头有个之前写好的函数,拿去用吧!
- // 分割字符串
- void StringSplit(CString strSource, CString strDivKey, CStringArray& strDest)
- {
- strDest.RemoveAll();
- CString strTmp;
- int pos = -1;
- pos = strSource.Find(strDivKey);
- while (pos >= 0)
- {
- strTmp = strSource.Left(pos);
- if (strTmp.GetLength() > 0)
- {
- strDest.Add(strTmp);
- strSource = strSource.Right(strSource.GetLength() - strTmp.GetLength() - strDivKey.GetLength());
- }
- else
- {
- strSource = strSource.Right(strSource.GetLength() - strDivKey.GetLength());
- }
- pos = strSource.Find(strDivKey);
- }
- if (pos < 0 && strSource.GetLength() > 0)
- {
- strDest.Add(strSource);
- }
- }
复制代码 |
|