I assume you meant how many words the sentence has. In that case, you can use find() to search for spaces, which will give you a general approximation of the number of words in the string.
myString.find(' ') //will return the index of the first space it finds
//note the space charecter ' ', it needs to know what to find (search for)
//example
int index = myString.find(' ');
if( index > 0 ) //index will be -1 if no space (' ') was found
cout << myString[index]; //if a space was found, we print it
//you can also supply a starting point for the search
string name = "Chris L. D."int index = name.find(' ', 6); //now it is only looking for a space (' ') at or past the 6th index
cout << index; //it will print 8, because the spaces are at the 5th and 8th indexes,
// but 8 is the smallest index larger then 6 (the first space at or past index 6)
i think its not hard to write some answer for that problem i dont need copy paste something i need solution i dnt need the sh t not fck ng hard problem is it for you
if you dont want to help than dont give any answr i am not interest of this crap i just have do my lesson
I don't feel like doing your homework for you, especially not for free. You can take your attitude and feel free to go elsewhere. Mathead200 has given you more than enough information to solve to problem yourself.
homework :)) what you think writing some codes makes you Scientist or a hero :)
this question answer not FBI secret :))
so what i am trying to say sharing information is plus you information
anyway thank you for not answering my question
CHANGE THAT FORUM MAKE IT WE DONT DO YOUR HOMEWORK WE DONT GIVE SOLUTION WE JUST GIVE MORE COMPLEX PROBLEMS PLUS TO YOUR HOMEWORK && PROJECTS
so what i am trying to say sharing information is plus you information
anyway thank you for not answering my question
CHANGE THAT FORUM MAKE IT WE DONT DO YOUR HOMEWORK WE DONT GIVE SOLUTION WE JUST GIVE MORE COMPLEX PROBLEMS PLUS TO YOUR HOMEWORK && PROJECTS
and then we smile your helpless situations :)
You're welcome. Thank you for not trying to do the problem assigned to you yourself.
I get the impression you could get help with homework if you were polite enough.
If they think they can help you by giving you clues that may seem cryptic at first, then think about it respecting that they gave any attention to your problem at all, and then if unable to overcome the problem still, ask for help again.
It is a tendency of people who give free help to want to help you through more than just doing homework for you, but actually giving you clues so that you can solve the problem yourself which is a better learning experience and will help you far more overall and in the long-term.
And if people selectively choose against helping with your homework then it's really their prerogative.
If you don't think we are that smart then prove us wrong. Go do the problem yourself and show us how easy it is... And, I started to get sarcastic around this post: http://cplusplus.com/forum/beginner/43389/#msg234490