VC CString 操作

来源:百度知道 编辑:UC知道 时间:2024/05/29 08:22:32
比如:
CString str="It's a beautiful day.";
要找到第二个空格后把"It's a "从str中删除,这个怎么实现?

int iIndex = str.Find(' ');
iIndex = str.Find(' ',iIndex+1);
str = str.Right(str.GetLength()-iIndex-1);

这样就可以了.

str.Right(str.GetLength()-6);
6是你要删除的字符数。
或者直接
str.Right(int x);
x是你要保留的右半部分的字符数(自己计算吧)