您的位置:首页 > 其它

CString类常用方法----Left(),Mid(),Right()

2009-12-12 16:20 459 查看
CString Left( int nCount ) const; //从左边1开始获取前 nCount 个字符

CString Mid( int nFirst ) const; //从左边第 nCount+1 个字符开始,获取后面所有的字符

CString Mid( int nFirst, int nCount ) const; //从左边第 nFirst+1 个字符开始,获取后面 nCount 个字符

CString Right( int nCount ) const; //从右边1开始获取从右向左前 nCount 个字符

注:

在函数后面加 const 的意思是:

如果一个类声明了一个常量对象,这个对象只能使用后边带 const 这个的方法.

例:

CString a,b;
a = "123456789";

b = a.Left(4); //值为:1234
b = a.Mid(3); //值为:456789
b = a.Mid(2, 4); //值为:3456
b = a.Right(4); //值为:6789
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: