CString strTemp;
//去掉最后一个字符
strTemp = strTemp.Left(strTemp.GetLength()-1);
//或
strTemp.SetAt(strTemp.GetLength()-1, 0);
//字符、字符串替换函数
//删除strTemp中某个字符或字符串
strTemp.Replace('*', '');//strTemp.Remove('*');
strTemp.Replace("123", "");
//替换strTemp中的某个字符或字符串
strTemp.Replace('*', '?');
strTemp.Replace("//", "////");//单斜杠替换成双斜杠
此外还有Left,Right,Mid,Find,ReverseFind,MakeLower,MakeUpper,MakeReverse,Delete(nIndex, nCount=1)
本文介绍了使用CString进行字符串处理的方法,包括去除特定字符、替换字符或子串等实用技巧,并提供了具体的代码示例。
902

被折叠的 条评论
为什么被折叠?



