#include<iostream>
using namespace std;
int main()
{
string str="abcd123588451236798";
string s="123"
// cout<<str.find("123")<<endl;这样也行
cout<<str.find(s)<<endl; //使用find判断括号str里面是否包含子串123
//有则返回首次出现的位置,没有这返回string::npos;
cout<<str.find(s,6)//第二数字是指从指定的位置开始查
return 0;
}
C++中find函数的用法
最新推荐文章于 2024-03-20 21:28:06 发布