So, I'm reading C++ Primer 5th edition, I get to chapter 5, and, I'm not sure how to go about solving one of the exercises.
When I get stuck I typically look at how the problem was solved here https://github.com/Mooophy/Cpp-Primer.
But there's a fatal error in how they solve it.
They use pair, and when I look that up in the back of the book, that type doesn't appear for about 230 more pages, and isn't even mentioned beforehand, as they sometimes do with "there's this we'll discuss later"
The exercise is as follows.
Write a program to read strings from standard input looking for duplicated words. The program should find places in the input where one word is followed immediately by itself. Keep track of the largest number of times a single repetition occurs and which word is repeated. Print the maximum number of duplicates, or else print a message saying that no word was repeated. For example, if the input is
how now now now brown cow cow
the output should indicate that the word now occurred three times.
I'm thinking that I'd start with a vector of strings, and a string variable, use a while loop to get input into the string variable, using .push_back to put the strings into the vector.
Then create a for loop to go through the string vector, comparing the current string to the next one, and upping a counter.
My issue being, what do I do to make it so, if I find say 3 of a word, and then 4 of a different word, make it use the 4, not the 3, and not have a counter just go from 3 to 7?