c++ 查找string子串是否存在

#include 
#include 
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;
}

你可能感兴趣的:(STL,杂项,c++,string)