下载此文档

cstring类相应函数.docx


文档分类:高等教育 | 页数:约20页 举报非法文档有奖
1/20
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/20 下载此文档
文档列表 文档介绍
CString 类
一、常用成员函数
1. int GetLength ( ) const;
说明:获取 CString 类对象包含字符串的长度(字符数)。
2. BOOL IsEmpty ( ) const;
说明:测试 CString 类对象包含的字符串是否为空。
3. void Empty ( ) ;
说明:使 CString 类对象包含的字符串为空字符串。
4. TCHAR GetAt ( int nIndex ) const;
说明:获得字符串指定位置处的字符。
5. TCHAR operator [] ( int nIndex  ) const;
说明:获得字符串指定位置处的字符,作用和 GetAt ()一样。
6. void SetAt ( int nIndex, TCHAR ch ) ;
说明:设定字符串指定位置处的字符。
7. operator LPCTSTR ( ) const;
说明:返回指向储存在 CString 类对象内的字符串指针。
8. Mid
Mid 函数有两个重载函数:
CString Mid ( int nFirst ) const; throw ( CMemoryException );
获取从 nFirst 位置开始的子串。
CString Mid ( int nFirst, int nCount ) const; throw ( CMemoryException ) ;
获取从 nFirst 位置开始包含  nCount 个字符的子串。
 Left ( int nCount ) const;throw ( CMemoryException );
说明:获取字符串左边 nCount 长度的字符串。
 Right ( int nCount ) const; throw ( CMemoryException );
说明:获取字符串右边 nCount 长度的字符串。
 SpanIncluding ( LPCTSTR lpszCharSet ) const;throw ( CMemoryException ) ;
说明:从字符串中提取包含在指定字符集 lpszCharSet 中的字符的子串。它从字符串的第一个字符开始,直到遇到不属于
lpszCharSet 中的字符为止。
 SpanExcluding ( LPCTSTR lpszCharSet ) const;throw ( CMemoryException );
说明:从字符串中提取不包含在指定字符集 lpszCharSet 中的字符的子串。
13. MakeUpper
将字符串中所有的字符全部转化成大写形式。
14. MakeLower
将字符串中所有的字符全部转化成小写形式。
15. MakeReverse
将字符串倒置,即将字符的顺序颠倒,第一个字符变成最后一个字符。
 Replace ( TCHAR chOld, TCHAR chNew );
int Replace ( LPCTSTR lpszOld, LPCTSTR lpszNew );
说明:将字符串中的字符 chOld 或字符子串 lpszOld 替换成新的字符 chNew 或字符串 lpszNew 。
17. void CString::TrimLeft ( TCHAR chTarget );
void CString::TrimLeft ( LPCTSTR lpszTargets ) ;
说明:删除字符串左边开头的字符或字符子串,参数缺省时删除左边的空格。
 CString::TrimRight ( TCHAR chTarget );
void CString::TrimRight ( LPCTSTR lpszTargets ) ;
说明:删除字符串右边开头的字符或字符子串,参数缺省时删除右边的空格。
19. Find
原型:
int Find ( TCHAR ch ) const;
int Find ( LPCTSTR lpszSub ) const;
int Find ( TCHAR ch, int nStart ) const;
int Find ( LPCTSTR pstr, int nStart ) const;
说明:在字符串中查找指定的字符或字符串。参数 ch 为要查找的字符; lpszSub 为要查找的字符子串;  nStart 指定查找的起始位
置,如缺省为从最左边开始; pstr 指向欲查找子串的指针。

原型: i

cstring类相应函数 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数20
  • 收藏数0 收藏
  • 顶次数0
  • 上传人aisheng191
  • 文件大小93 KB
  • 时间2018-11-05