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);
}
}
// 分割
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);
}
}
相关文章推荐
- Leetcode|Median of Two Sorted Arrays
- dictionaryWithObjectsAndKeys
- cocos2d内存管理
- TTL门与COMS门区别
- 自定义分区标题不随着table滑动
- hdu 1102 Constructing Roads
- 2015多校联合第八场hdu5384Danganronpa AC自动机
- C++中extern “C”含义深层探索
- Unity3d C# Socket 下载文件 (同步到)
- 熟悉linux-安装tomcat
- Mac快速配置adb大法
- 46 Permutations
- [c#]记一次实验室局域网的ARP欺骗
- Web 服务编程,REST 与 SOAP
- 1.1 JavaScript高级程序设计(第3版) 笔记---对象
- 利用python发布新浪微博
- [POJ 1988]Cube Stacking[带权并查集]
- swift的基本使用(3)嵌套函数和闭包
- Visual Studio 2015编译安装OpenCV 3.0和opencv_contrib
- IOS_UITabBarController