#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
string str("i love you");
string str1 = "youf";
string::iterator ix = search(str.begin(), str.end(), str1.begin(), str1.end());
if (ix == str.end())
cout << "connot find it" << endl;
else
cout << ix-str.begin();
int n=str.find_first_of("sdaadosf");
cout << n << endl;
} stl:find _first_of与search用法
最新推荐文章于 2023-05-04 22:07:23 发布
本文展示如何使用C++标准库中的search函数来查找一个字符串是否包含另一个字符串,并获取其位置。同时,演示了find_first_of函数的用法,用于找到字符串中第一个出现在指定字符集中的字符的位置。
152

被折叠的 条评论
为什么被折叠?



