Answers for "c++ if string contain a specific character"

C++
9

how to check string contains char in c++

std::string s = "Hello";
if (s.find('e') != std::string::npos)
    cout << "Found";
else
    cout << "Not Found";
Posted by: Guest on August-23-2020
7

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

Code answers related to "c++ if string contain a specific character"

Browse Popular Code Answers by Language