c++ number of occurrences of a character in a string code example
Example 1: count a character in a string c++
count(str.begin(), str.end(), 'e')
Example 2: count occurrences of character in string c++
std::string s = "a_b_c";
size_t n = std::count(s.begin(), s.end(), '_'); // n=2