Finding the maximum value from the map
unsigned currentMax = 0 ; char arg_max ; for ( it = occ . begin ( ) ; it != occ . end ( ) ; ++ it ) { if ( it -> second > currentMax || ( it -> second == currentMax && it -> first > arg_max ) ) { arg_max = it -> first ; currentMax = it -> second ; } }