find()
函数的头文件 #include
#include<cstdio>
#include<string>
#include<iostream>
using namespace std;
int main()
{
//查找字串首次出现的位置
string str= "efgacabcabca";
int a = str.find("bca"); //6
printf("%d\n", a);
//查找单个字符第一次或者最后一次出现的位置
int b = str.find_first_of("g"); //2
int c = str.find_last_of("b"); //9
printf("%d\n%d\n", b, c);
//反向查找字符串出现的位置==查找字符串最后一次出现的位置
int d = str.rfind("bca");
printf("%d\n", d); //9
system("pause");
return 0;
}