zoukankan      html  css  js  c++  java
  • string::find_first_not_of

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

  • 相关阅读:
    清除所有缓存命令
    web前端工程师面试技巧 常见问题解答
    Web前端开发面试技巧
    JavaScript
    JavaScript Cookie
    JavaScript 计时事件
    javascript 弹窗
    JavaScript Window Navigator
    JavaScript Window History
    JavaScript Window Location
  • 原文地址:https://www.cnblogs.com/xpylovely/p/12090148.html
Copyright © 2011-2022 走看看