#include<iostream>
#include<string>
using namespace std;
int main()
{
string a = "apple banana orange";
string b = "banana";
string::size_type idx = a.find(b);
if (idx != string::npos)
cout << "有" << endl;
else
cout << "没有" << endl;
return 0;
}
//nops表示size_type的最大值,表示不存在的位置。find成员的返回值是size_type
C++查找字符串中是否有某个子串
最新推荐文章于 2024-07-25 09:44:13 发布