Posted on 2010-06-13 11:54
Tinpont 阅读(6642)
评论(2) 编辑 收藏 引用 所属分类:
C++/MFC
1 CString res;
2 CString str = _T("abcdefghijklmn");
3 res = str.Mid(2,3); //从第3位字母开始,共取3个字符
4 ASSERT(res == _T("cde"));
5
6 res = str.Left(3); //从左边数起,共取3个字符
7 ASSERT(res == _T("abc"));
8
9 res = str.Right(3); //从右边数起,共取3个字符
10 ASSERT(res == _T("lmn"));
11
12 res = str.SpanIncluding(_T("edcba")); //遇到参数里没有的字符即停下,返回停下之前的字符串
13 ASSERT(res == _T("abcde"));
14
15 res = str.SpanExcluding(_T("fgb")); //遇到参数里面有的字符即停下,返回停下之前的字符串
16 ASSERT(res == _T("a"));
17
18