string str ("There are two needles in this haystack."); string str2 ("needle"); if (str.find(str2) != string::npos) { //.. found. }

c++ check if string contains substring

if (s1.find(s2) != std::string::npos) { std::cout << "found!" << '\n'; }

c++ contains

Similar Code Examples