bool _splite(CString strSrc, CString strSplite,CStringArray& arDes)
{
arDes.RemoveAll();//初始化
while(strSrc.GetLength()>0){
int pos = strSrc.Find(strSplite,0);//定位分割符
CString strLeft;
if(pos!=-1){
//定位成功
strLeft = strSrc.Left(pos);//前面的字符串为新的分割单元
arDes.Add(strLeft);
strSrc = strSrc.Right(strSrc.GetLength()-pos-strSplite.GetLength());//指定新的分割对象
if(strSrc.IsEmpty()){
//如果已空
arDes.Add(strSrc);//剩下的字符串为分割单元
break;
}
}else{
//定位不成功
strLeft = strSrc;//将原字符串作为分割单元入目标数组
arDes.Add(strLeft);
strSrc.Empty();//清空原字符串
}
}
return arDes.GetSize()>1;//如果分割单元数量大于1定义为操作成功
}
CStrring splite分割
最新推荐文章于 2022-06-09 20:52:09 发布