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

C++
2

find character in string c++

auto char_to_find = 'a'
if (str.find(char_to_find) != std::string::npos) {
    // character found
}
Posted by: Guest on September-15-2020
3

check if char in string c++

std::string s = "hell[o";
if (s.find('[') != std::string::npos)
    ; // found
else
    ; //
Posted by: Guest on September-14-2020

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

Browse Popular Code Answers by Language