zoukankan      html  css  js  c++  java
  • 【顺序容器 || 09】

    string搜索操作

    1. find函数简介

    size_t find ( const string& str, size_t pos = 0 ) const;
    size_t find ( const char* s, size_t pos, size_t n ) const;
    size_t find ( const char* s, size_t pos = 0 ) const;
    size_t find ( char c, size_t pos = 0 ) const;

     2. find_first_of函数简介

    size_t find_first_of ( const string& str, size_t pos = 0 ) const;
    size_t find_first_of ( const char* s, size_t pos, size_t n ) const;
    size_t find_first_of ( const char* s, size_t pos = 0 ) const;
    size_t find_first_of ( char c, size_t pos = 0 ) const;

    函数原型:

    size_t find_first_of ( const string& str, size_t pos = 0 ) const;
    size_t find_first_of ( const char* s, size_t pos, size_t n ) const;
    size_t find_first_of ( const char* s, size_t pos = 0 ) const;
    size_t find_first_of ( char c, size_t pos = 0 ) const;

    参数和find基本相同,不在赘述!

    特别注意:

    find_first_of 函数最容易出错的地方是和find函数搞混。它最大的区别就是如果在一个字符串str1中查找另一个字符串str2,如果str1中含有str2中的任何字符,则就会查找成功,而find则不同;

  • 相关阅读:
    定时器
    js中script的上下放置区别 , Dom的增删改创建
    函数声明与应用
    常规选择器
    表格的制作
    流程控制
    For循环
    洛谷P1419寻找段落
    洛谷P1021邮票面值设计
    洛谷P3119草鉴定
  • 原文地址:https://www.cnblogs.com/sunbines/p/14457055.html
Copyright © 2011-2022 走看看