C++中STL容器的find的应用
2013-08-02 21:05
381 查看
string类的查找函数: int find(char c, int pos = 0) const;//从pos开始查找字符c在当前字符串的位置 int find(const char *s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置 int find(const char *s, int pos, int n) const;//从pos开始查找字符串s中前n个字符在当前串中的位置 int find(const string &s, int pos = 0) const;//从pos开始查找字符串s在当前串中的位置 //查找成功时返回所在位置,失败返回string::npos的值 int rfind(char c, int pos = npos) const;//从pos开始从后向前查找字符c在当前串中的位置 int rfind(const char *s, int pos = npos) const; int rfind(const char *s, int pos, int n = npos) const; int rfind(const string &s,int pos = npos) const; //从pos开始从后向前查找字符串s中前n个字符组成的字符串在当前串中的位置,成功返回所在位置,失败时返回string::npos的值 int find_first_of(char c, int pos = 0) const;//从pos开始查找字符c第一次出现的位置 int find_first_of(const char *s, int pos = 0) const; int find_first_of(const char *s, int pos, int n) const; int find_first_of(const string &s,int pos = 0) const; //从pos开始查找当前串中第一个在s的前n个字符组成的数组里的字符的位置。查找失败返回string::npos int find_first_not_of(char c, int pos = 0) const; int find_first_not_of(const char *s, int pos = 0) const; int find_first_not_of(const char *s, int pos,int n) const; int find_first_not_of(const string &s,int pos = 0) const; //从当前串中查找第一个不在串s中的字符出现的位置,失败返回string::npos int find_last_of(char c, int pos = npos) const; int find_last_of(const char *s, int pos = npos) const; int find_last_of(const char *s, int pos, int n = npos) const; int find_last_of(const string &s,int pos = npos) const; int find_last_not_of(char c, int pos = npos) const; int find_last_not_of(const char *s, int pos = npos) const; int find_last_not_of(const char *s, int pos, int n) const; int find_last_not_of(const string &s,int pos = npos) const; //find_last_of和find_last_not_of与find_first_of和find_first_not_of相似,只不过是从后向前查找
实例详解一:http://blog.csdn.net/slience_perseverance/article/details/7783846
实例详解二:http://blog.csdn.net/caijun12358098/article/details/7536377
实例详解三:http://blog.csdn.net/youxin2012/article/details/9162415
相关文章推荐
- 实战c++中的vector系列--vector应用之STL的find、find_if、find_end、find_first_of、find_if_not(C++11)
- 实战c++中的vector系列--vector应用之STL的find、find_if、find_end、find_first_of、find_if_not(C++11)
- C++STL库中map容器常用应用
- C++ STL 基础及应用(6) 容器
- C++ 容器的综合应用的一个简单实例——文本查询程序
- C++ STL基本容器的使用
- C++面试笔记--STL模板与容器
- C++ STL 有关容器部分 priority_queue 优先级队列的基本操作以及认识案例
- C++ STL之min_element()与max_element()(取容器中的最大最小值)
- STL中Vector容器Find的使用(int查找)
- c++ stl中map容器的基本用法
- C++ —— STL容器分析(2)
- C++ STL 不同容器的比较 以及使用时机
- C++ 容器 综合应用 文本查询程序
- C++ STL基本容器的使用
- C++学习-STL容器
- 【C++ STL学习之四】容器list深入学习
- C++学习 STL之七:STL各种容器的使用时机详解
- 关于在STL容器list中使用find_if 函数
- C++ 动态数组类模板(向量容器)vector与STL用法总结