#include <iostream>
#include <string>
using namespace std;
int main()
{
std::string _Str = "abcdefg";
if (string _Tmpy= "def"; string::npos != _Str.find(_Tmpy)) // c++17 if、switch语句初始化
{
cout << "找到该字符串:" << _Tmpy << endl;
}
else
{
cout << "该字符串不在_Str中" << endl;
}
return 0;
}
c++ 查找string子串是否存在
于 2021-02-25 16:42:01 首次发布