Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1488610
  • 博文数量: 226
  • 博客积分: 3997
  • 博客等级: 少校
  • 技术积分: 2369
  • 用 户 组: 普通用户
  • 注册时间: 2010-06-19 17:26
个人简介

Never save something for a special occasion. Every day in your life is a special occasion.

文章分类

全部博文(226)

文章存档

2018年(5)

2017年(11)

2016年(1)

2015年(17)

2014年(14)

2013年(30)

2012年(5)

2011年(52)

2010年(107)

分类: Windows平台

2015-03-06 16:59:36

MFC-CSTRING 字符串分割

CString strSrc = _T("1++2+3+4");
CStringArray strResult;

CString strGap = _T("+"); 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 - 1);
    nPos = strSrc.Find(strGap);
} if (!strSrc.IsEmpty()) {
   strResult.Add(strSrc);
} int nSize = strResult.GetSize(); for (int i = 0; i < nSize; i++)
{
    OutputDebugString(strResult.GetAt(i) + _T("\n"));
}

阅读(2107) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~