Let's say the input is "My name is Michael, and I am 36 years old."
I'm using getline(cin, str) and then looking for spaces to be new indices to create substrings. Is there an easier way?
By edit words, I mean separate the sentence into words without spaces and then doing things with the words. The problem I have right now is that I have no way of getting the last word.
If all you want is the last word you could use the std::string.find_last_of() function to find the last whitespace character, then use the substr() function to extract that word. You could also use a stringstream and extract each word from the string using the extraction operator.