#include <string>
#include <map>
#include <iostream>
using namespace std;
int main()
{
map<string,int> dict;
map<string,int>::iterator it;
char str[] = "This is a pen. That is a pencil. He is tall.";
char *p;
p = strtok(str, " .,");
while(p){
if((it=dict.find(p))!=dict.end()) it->second++;
else dict.insert(pair<string, int>(p, 1));
p = strtok(0, " .,");
}
//result
for(it=dict.begin(); it!=dict.end(); it++)
cout << it->first << " : " << it->second << endl;
}