cpp string contains code example
Example 1: find character in string c++
auto char_to_find = 'a'
if (str.find(char_to_find) != std::string::npos) {
}
Example 2: c++ string contains
if (string1.find(string2) != std::string::npos) {
std::cout << "found!" << '\n';
}
Example 3: c++ contains
if (s1.find(s2) != std::string::npos) {
std::cout << "found!" << '\n';
}
Example 4: find substring in string c++
std::string parentstring = "Hello Agnosticdev, I love Tutorials";
std::string substring = "Agnosticdev";
auto index = parentstring.find(substring);