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É

Recommended Answers

All 4 Replies

count[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

Do you know what a map is?

This code is not complete

Explain it further,so I can tell you the write code

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.