count char* C++ 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
Example 3: c++ char define
// syntax:
// char <variable-name>[] = { '<1st-char>', '<2nd-char>', ... , '<Nth-char>', '\0'};
// example (to store 'Hello' in the YourVar variable):
char YourVar[] = {'H','e','l','l','o','\0'}; // NOTE: the \0 marks the end of the char array