I just started using c++ and I have a problem with an exercise that I am working on.
What I have to do is to read in two words separated by a space inputted by the user into two variables. Also, I need to check how many words the user has entered.
Let's say the two string variables are word1 and word2;
I need word1 = a and word2 = b
I have tried using cin << word1 << word1; and it works for two variables.
However, the user might only input 1 word and so I need to detect it.
My question is: Is there a way to detect the number of words the user has inputted?
Thanks a lot!