how can i find the first word in my sentence having 'w' character. This character can be present anywhere in my word. Lets take an example of sentence "Hi, what are you doing here abxwxyz?
So the result should be what.

I am assuming you mean the first word that starts with 'w'.

If its a structural sentence, then find the first 'w' Then check if the character before it is a space. If so then its what you are looking for. Be sure to watch out, if w is found at index 0. Then thats your answer.

hi altp,

thanks for the hint. but i am new to C++. i dnt know how to read a sentence in words.
shall i use vector?

thanks!

If you know vectors, you certainly know how to read a string. If not, maybe you need to read your text about strings and input.

i got an idea about vector from searching google.
i know how to read a string, but what i know is reading char by char that will not solve a problem.
because then i can find w but how will i extract the word haing w.
please help and correct if my approach is wrong.

If you know vectors, you certainly know how to read a string. If not, maybe you need to read your text about strings and input.

Did you read about strings like I mentioned? What else can I do for you. Write it myself, maybe?

This question has already been answered. Start a new discussion instead.