string (1) |
size_t find_first_not_of (const string& str, size_t pos = 0) const noexcept; |
---|---|
c-string (2) |
size_t find_first_not_of (const char* s, size_t pos = 0) const; |
buffer (3) |
size_t find_first_not_of (const char* s, size_t pos, size_t n) const; |
character (4) |
size_t find_first_not_of (char c, size_t pos = 0) const noexcept; |
功能:查找在前面出现后面没有的位置
返回值:成功返回找到的位置,没找到返回string::npos
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s1("abcde");
string s2("aaccbbddeeff");
size_t n = s2.find_first_not_of(s1);
cout << n << endl;
const char *s3 = "abcdefghij";
string s4("mabcdefghijk");
cout << s4.find_first_not_of(s3) << endl;
cout << s4.find_first_not_of(s3, 1) << endl;
cout << s4.find_first_not_of(s3, 1, 5) << endl;
string s5("mabcdefghij");
cout << (n = s5.find_first_not_of(s3, 1)) << endl;
if(n == string::npos)
cout << "not found diffence string::npos" << endl;
return 0;
}