c++ program that count the occurrences of a character code example
Example 1: string count occurrences c++
#include <algorithm>
std::string s = "a_b_c";
size_t n = std::count(s.begin(), s.end(), '_'); //n=2
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