admin管理员组文章数量:1567250
1、 CString::Find
在一个较大的字符串中查找字符或子字符串 ,返回此CString对象中与需要的子字符串或字符匹配的第一个字符的从零开始的索引;如果没有找到子字符串或字符则返回-1。
int Find( TCHAR ch ) const;
int Find( LPCTSTR lpszSub ) const;
int Find( TCHAR ch, int nStart ) const;
int Find( LPCTSTR pstr, int nStart ) const;
其中,nStart 字符串中开始搜索的字符的索引,如果是0,则是从头开始搜索。如果nStart不是0,则位于nStart之前的字符不包括在搜索之内,但是会包括nStart处的字符。
CString s( "abcdef" ); int n = s.Find( 'c' ); // 结果 n = 2 int f = s.Find( "de" ) ; // 结果 f = 3
CString str("The stars are aligned"); int n = str.Find('e',2); //结果 n = 2
2、CString::Mid
CString Mid( int nFirst, int nCount ) const;
此成员函数从此CString对象中提取一个长度
版权声明:本文标题:Cstring中的 Find()、Mid()、Replace() 用法 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1727342165a1109547.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论