Character Counting

Feb 28, 2011 at 10:29pm
So I have to finish a program as a project for my C++ class. I have to input a sentence and have the program count the number of words in the sentence and then count how many of each character there are in that sentence. Example: I Love Pie

The program needs to print:
There are three words.
There are the count of these characters.

I=2
L=1
O=1
V=1
E=2
P=1

I have read my book and tried so many different ways. Please help me. If possible can you write that piece of the code and then break it down explaining what action does what. Please and thank you :D
Mar 1, 2011 at 12:48pm
A map<char,int> would help you in this task: http://www.cplusplus.com/reference/stl/map/
Topic archived. No new replies allowed.