string::rfind

来源:互联网 发布:淘宝类目分析 编辑:程序博客网 时间:2024/06/04 18:39

The position of the last occurrence in the string of the searched content.
If the content is not found, the member value npos is returned.

 

 

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// string::rfind#include <iostream>#include <string>using namespace std;int main (){  string str ("The sixth sick sheik's sixth sheep's sick.");  string key ("sixth");  size_t found;  found=str.rfind(key);  if (found!=string::npos)    str.replace (found,key.length(),"seventh");  cout << str << endl;  return 0;}


Output:
The sixth sick sheik's seventh sheep's sick.
nnd,下载C/C++手册上写的很是费解
size_type rfind( const string& str, size_type index );
returns the location of the first occurrence of str in the current string, doing a reverse search from index, string::npos if nothing is found,
达人指导下,这段话啥意思没写错吧?