Possible Duplicate:
C++ function to count all the words in a string
So I have a line of words which i stored in a string using C++. i.e. "There was a farmer named Billy\n"
I want to know the number of words in the string (i.e. There are currently 6 words in it). Can anyone tell me how to do this? If this is not possible is there a way I can count the number of spaces in the string (i.e. " "). Let me know THanks!