I have a variable of type std::string. I want to check if it contains a certain std::string. How would I do that?
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
string str;
cin >> n;
string str1 = "not";
while(n--)
{
cin >> str;
cout << "2";
if(str.size() >= str1.size())
{
if (str.find(str1) != string::npos)
{
cout << "1";
}
else
cout << "2";
}
}
return 0;
}
Input:
2
i do not have any fancy quotes
when nothing goes right go left
output: no output