CString分割出指定字符串

it2024-02-18  69

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); } }

 

最新回复(0)