int main()
{
map<string,size_t> count;
string word;
while(cin >> word)
count[word]++; --------(1)
for(auto it=count.begin();it!=count.end();++it)
cout << it->first << ": "<< it ->second <<endl;
I donot understand the code particularly the line (1)
Could anyone can explainÉ
skyyadav
0
Light Poster
Recommended Answers
Jump to Postcount[word]++;
means you are adding a word into count and incrementing the size.
Look at the example in this link of how contents are added using <map>:
Click Here
All 4 Replies
kal_crazy
13
Junior Poster
Moschops
683
Practically a Master Poster
Featured Poster
techofunda
0
Newbie Poster
techofunda
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.