What's the easiest way to find how many times every word appears in a string?
For ex. in : "Outside there are twelve birds,twelve cars and twelve trees".
Should I just search the string for the first whitespace,save the position,then exatract everything that was before the first whitespace,save it in a string,then delete everythign that was before the whitespace,after that search the string for that word,and everytime i find it,delete it(and increment an int in order to know how many times i found it)? Then repeat the process?
Is there a better way?
Is is possible to save everything word that the user inputs via console in a vector?
like:
for every word received as input,vector.push_back(word)
I thought about that,but I can't figure a way to take each word separately,I mean when the user writes a sentence and presses enter,all words will be received at once...