how to count the number of occurence of an element in a string in c++ code example
Example: count occurrences of character in string c++
std::string s = "a_b_c";
size_t n = std::count(s.begin(), s.end(), '_'); // n=2
std::string s = "a_b_c";
size_t n = std::count(s.begin(), s.end(), '_'); // n=2