How to check that s1 is the substring of s2 using sting.find() function?
This example might clear it up.
string str = “geeksforgeeks a computer science”;
string str1 = “geeks”;
size_t found = str.find(str1);
if(found != string::npos) cout<<“Found”;
else cout<<“Not Found”;
If a substring is found, the function returns the index where the first occurence of the substring begins.
Else it returns the value string::npos whose actual value is 18446744073709551615.
If my answer is able to answer your query, please mark the doubt as resolved.