您的位置:首页 > 其它

CString的split功能

2015-09-08 19:25 267 查看
mfc的CString没有split方法,自己实现之:

// 分割

void CdecDemoDlg::SplitStr(CString strSrc, CString strGap, CStringArray &strResult)

{

int nPos = strSrc.Find(strGap);

CString strLeft = _T("");

while (0 <= nPos)

{

strLeft = strSrc.Left(nPos);

if (!strLeft.IsEmpty())

{

strResult.Add(strLeft);

}

strSrc = strSrc.Right(strSrc.GetLength() - nPos - strGap.GetLength());

nPos = strSrc.Find(strGap);

}

if (!strSrc.IsEmpty())

{

strResult.Add(strSrc);

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: