how to check if character is in a string c++ code example
Example 1: 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";
Example 2: check if character in string c++
std::string s = "hell[o";
if (s.find('[') != std::string::npos)
; // found
else
; //