Check out example codes for "count occurrences of character in string c++". It will help you in understanding the concepts better.

Code Example 1

std::string s = "a_b_c";
size_t n = std::count(s.begin(), s.end(), '_'); // n=2

Code Example 2

count(str.begin(), str.end(), 'e')

Learn ReactJs, React Native from akashmittal.com