功能

查找子串在母串中最后一次出现的位置

使用

  1. string s("abcdABCD123");
  2. string::size_type position = s.find_last_of("123");

例子说明

  1. # include<iostream>
  2. # include<algorithm>
  3. using namespace std;
  4. int main(void)
  5. {
  6. ////find函数返回类型 size_type
  7. string s("abcdABCD123");
  8. string::size_type position;
  9. //find 函数返回 AB 在 s 中的下标位置
  10. position = s.find_last_of("123");
  11. printf("s.find_last_of(\"123\") is :%d\n", position);
  12. }

输出结果:

s.find_last_of(“123”) is :10