how to check a char in a string in c++ code example
Example 1: find character in string c++
auto char_to_find = 'a'
if (str.find(char_to_find) != std::string::npos) {
// character found
}
Example 2: check if char in string c++
std::string s = "hell[o";
if (s.find('[') != std::string::npos)
; // found
else
; //