说明:CStringArray只能用引用传入,不可以作为函数返回值,因为CStringArray集成的CObject不支持复制构造

void SplitCString(const CString& _cstr, const CString& _flag, CStringArray& _resultArray)
{
CString strSrc(_cstr);

CStringArray& strResult = _resultArray;
CString strLeft = _T("");

int nPos = strSrc.Find(_flag);
while(0 <= nPos)
{
strLeft = strSrc.Left(nPos);
if (!strLeft.IsEmpty())
{
strResult.Add(strLeft);
}
strSrc = strSrc.Right(strSrc.GetLength() - nPos - 1);
nPos = strSrc.Find(_flag);
}

if (!strSrc.IsEmpty()) {
strResult.Add(strSrc);
}
}

相关文章:

  • 2022-01-12
  • 2021-09-07
  • 2022-02-01
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2021-11-08
猜你喜欢
  • 2022-02-03
  • 2022-12-23
  • 2022-01-27
  • 2022-01-27
  • 2021-11-26
  • 2021-11-20
  • 2022-02-14
相关资源
相似解决方案