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;
}

posted @ 2019-12-24 12:19  MoonXu  阅读(671)  评论(0编辑  收藏  举报