1 string类find_first_not_of ()方法
2
3 原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://xfqxj.blog.51cto.com/2342497/512015
4 #include <string>
5
6 #include <iostream>
7 using namespace std;
8
9 int main()
10 {
11 string strFirst ( "abced" ),strSecond("abc abc abd def");
12 cout<<strFirst.find("a")<<endl;//输出结果为0,说明a当前的索引位置为0
13
14 //函数原型:size_type find_first_not_of( Char ch, size_type index = 0 ) const;
15 //返回在字符串中首次不匹配 d 的首字符索引,从2开始。
16 cout<<strFirst.find_first_not_of ( "d" ,2)<<endl;//输出结果为 2
17
18 cout<<strSecond.length()<<endl;//输出结果为15
19 cout<<strSecond.find_first_not_of("abc",4)<<endl;//输出结果为7
20 system("pause");
21 }