c++中 string 类的find函数的用法

来源:互联网 发布:小米网络机顶盒看卫视 编辑:程序博客网 时间:2024/05/16 17:30

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

0 0
原创粉丝点击