count string length c++ code example
Example 1: count a character in a string c++
count(str.begin(), str.end(), 'e')
Example 2: length of string c++
// string::length
#include <iostream>
#include <string>
int main ()
{
std::string str ("Test string");
std::cout << "The size of str is " << str.length() << " bytes.\n";
return 0;
}