- C 标准库
 - C 标准库
 
- C++ 标准库
 - C++ 库 - 主页
 - C++ 库 - <fstream>
 - C++ 库 - <iomanip>
 - C++ 库 - <ios>
 - C++ 库 - <iosfwd>
 - C++ 库 - <iostream>
 - C++ 库 - <istream>
 - C++ 库 - <ostream>
 - C++ 库 - <sstream>
 - C++ 库 - <streambuf>
 - C++ 库 - <原子>
 - C++ 库 - <复杂>
 - C++ 库 - <异常>
 - C++ 库 - <功能>
 - C++ 库 - <限制>
 - C++ 库 - <语言环境>
 - C++ 库 - <内存>
 - C++ 库 - <新>
 - C++ 库 - <数字>
 - C++ 库 - <正则表达式>
 - C++ 库 - <stdexcept>
 - C++ 库 - <字符串>
 - C++ 库 - <线程>
 - C++ 库 - <元组>
 - C++ 库 - <类型信息>
 - C++ 库 - <实用程序>
 - C++ 库 - <valarray>
 
C++ 字符串库 - rfind
描述
它在字符串中搜索由其参数指定的序列的最后一次出现。
宣言
以下是 std::string::rfind 的声明。
size_t rfind (const string& str, size_t pos = npos) const;
C++11
size_t rfind (const string& str, size_t pos = npos) const noexcept;
C++14
size_t rfind (const string& str, size_t pos = npos) const noexcept;
参数
str - 它是一个字符串对象。
len - 用于复制字符。
pos - 要复制的第一个字符的位置。
返回值
没有任何
例外情况
如果抛出异常,则字符串不会发生任何变化。
例子
在下面的 std::string::rfind 示例中。
#include <iostream>
#include <string>
#include <cstddef>
int main () {
   std::string str ("sairamkrishna mammahe is a one of the tech person in tutorialspoint.com");
   std::string key ("mammahe");
   std::size_t found = str.rfind(key);
   if (found!=std::string::npos)
      str.replace (found,key.length(),"tech");
   std::cout << str << '\n';
   return 0;
}
示例输出应该是这样的 -
sairamkrishna tech is a one of the tech person in tutorialspoint.com
字符串.htm