Answers for "how to check a substring in a string in c++"

C++
4

c++ check if string contains substring

string str ("There are two needles in this haystack.");
string str2 ("needle");

if (str.find(str2) != string::npos) {
//.. found.
}
Posted by: Guest on December-23-2020
0

c++ check substring

if (s1.find(s2) != std::string::npos) {
    std::cout << "found!" << 'n';
}
Posted by: Guest on July-07-2020
0

find substring in string c++

std::string parentstring = "Hello Agnosticdev, I love Tutorials";
std::string substring = "Agnosticdev";
auto index = parentstring.find(substring);
Posted by: Guest on September-15-2020

Code answers related to "how to check a substring in a string in c++"

Browse Popular Code Answers by Language