map<char,int>
1234567
string s = "whatever"; map < char, int > counter; // needs #include <map> for ( int i = 0; i < s.size(); i++ ) // chars in the string counter[ s[i] ] ++; // see http://www.cplusplus.com/reference/stl/map/begin/ for printing the results