string::find_last_not_of

#include <iostream>
#include <string>

using namespace std;
int main()
{
string s1("abcdemyyngl");
string s2("mngf");
size_t n = s1.find_last_not_of(s2);
cout << n << endl;
n = s1.find_last_not_of(s2, 6); //在s2中查找s1位置6之前的每个字符
cout << n << endl;
const char *s3 = "ghijy";
cout << s1.find_last_not_of(s3, 6) << endl;
cout << s1.find_last_not_of(s3, 5, 4) << endl;在s3的前4个字符中查找s1位置5前的字符
cout << s1.find_last_not_of('l', 8) << endl;
cout << s1.find_last_not_of('l', 7) << endl;
cout << s1.find_last_not_of('l') << endl;
return 0;
}

猜你喜欢

转载自www.cnblogs.com/xpylovely/p/12090830.html