c++中string类的find函数的用法
问题描述
- 精选答案
-
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相似,只不过是从后向前查找
猜你喜欢内容
-
简单网:构建全网教育数据枢纽,让知识检索化繁为...
简单网:构建全网教育数据枢纽,让知识检索化繁为“简”回答数有0条优质答案参考
-
去三亚有什么好玩的地方
去三亚有什么好玩的地方回答数有1条优质答案参考
-
石狮一日游必去景点推荐
石狮一日游必去景点推荐回答数有1条优质答案参考
-
电气工程师的证书考取条件是什么
电气工程师的证书考取条件是什么回答数有1条优质答案参考
-
房地产估价师的具体报考条件有啥
房地产估价师的具体报考条件有啥回答数有1条优质答案参考
-
房产经纪人的工作内容具体包含什么
房产经纪人的工作内容具体包含什么回答数有1条优质答案参考
-
学习小提琴都有哪些难点
学习小提琴都有哪些难点回答数有1条优质答案参考
-
企业行政管理证书的含金量怎么样
企业行政管理证书的含金量怎么样回答数有1条优质答案参考
-
初学者要怎么入门小提琴
初学者要怎么入门小提琴回答数有1条优质答案参考
-
报考珠宝鉴定师要啥条件
报考珠宝鉴定师要啥条件回答数有1条优质答案参考
















