首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

TrimRight解决思路

2013-07-08 
TrimRightCString oo _T(uu_Tempe_code)oo.TrimLeft(_T(uu_))oo.TrimRight(_T(_code))运行发现

TrimRight
CString oo = _T("uu_Tempe_code");
oo.TrimLeft(_T("uu_"));
oo.TrimRight(_T("_code"));

运行发现oo = Temp,为什么少个e?
[解决办法]
CString oo = _T("uu_Tempe_coda");
改成这样试试,就是把最后一个字母的e改成除Temp外的任何字母,如果正常就说明这个截取函数是截取所有一样的字母,而不是截取单词
[解决办法]
理解有问题,给个例子:
CString oo = _T("ccccooooddddeeee_code");
oo.TrimRight(_T("_code"));
结果是 “” !!!!!
就是说 从串尾开始 字串中 与  “_code” 一样的 全 删除。
Use the versions of this function that accept parameters to remove a particular character or a particular group of characters from the end of a string.

同样:
oo.TrimLeft(_T("_code"));
结果也是 “”

Use the versions of this function that accept parameters to remove a particular character or a particular group of characters from the beginning of a string.

热点排行