C++ String find_last_of()
 
 
C++ String find_last_of()
 
 此函数在字符串中搜索与字符串中指定的任何字符匹配的最后一个字符。
 
语法
 
 考虑两个字符串str1和str2、语法为: 
 
 
参数
 
  str: str是用于搜索的字符串。
 
  pos: 它定义了开始搜索的位置。
 
  n: 标识要搜索的字符的字符数。
 
  ch : 定义要搜索的字符
 
返回值
 
 它返回不匹配的第一个字符的位置。
示例1 
 
 让我们看一个简单的示例。
 
 
  
  #include<iostream>
using namespace std;
int main()
{
string str = "I love India";
cout<< "String contains :" << str <<'\n';
cout<< str.find_last_of("love");
return 0;
             }  
   
  
  输出: 
 
 
  
  String contains : I love India
    5 
   
  
示例2 
 
 让我们看一下指定开始搜索位置的简单示例。
 
 
  
  #include<iostream>
           using namespace std;
          int main()
        {
        string str = "C++ Tutorial";
       cout<< "String contains :" << str <<'\n';
      cout<< str.find_last_of("Tutorial",3);
       return 0;
       }