I'm currently on an exercise that specifies that I find any repeated words, "the the" for example, in a string, print the word that is repeated and how many times said word is repeated using a while loop that reads one word at a time and break statements when a repeated word is found. Having a bit of a falling out with iterators tonight and I'm not doing to well.
I tried using an iterator to find each character in the string that was a space and indicating that this is the start of a new word and the end of the word just processed. But I kept getting syntactical errors. Not really my strong point.
iebwen (9)
I'm currently on an exercise that specifies that I find any repeated words, "the the" for example, in a string, print the word that is repeated and how many times said word is repeated using a while loop that reads one word at a time and break statements when a repeated word is found. Having a bit of a falling out with iterators tonight and I'm not doing to well.
We don't know what you are taught previously. So we cannot solve your homework for you.
I had a project that parsed and wrote pickit files for a bot... and for that I generally loaded each word into a string, each string in a line into a vector of strings, and each line of vectored strings into a multidimensional array (vector<vector<string>>). Spaces weren't loaded because file loading considers spaces as separators between inputs.
That said, there were lines with irrelevant data, and lines with spaces that could cause issue while parsing, and using exclusion keys, string searches and replacements I was able to filter out my problems.