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 xyzwy! what are you doing here?
So the result should be "xyzwy".
int main() {
using namespace std;
string sentence = "Hi xyzwy! what are you doing here?";
istringstream iss(sentence);
copy(istream_iterator<string>(iss),
istream_iterator<string>(),
ostream_iterator<string>(cout, "\n"));
#include <iostream>
#include <string>
#include <sstream>
int main() {
usingnamespace std;
string sentence = "Hi xyzwy! what are you doing here?";
string word;
istringstream iss(sentence);
while (iss >> word)
if (string::npos != word.find('w'))
break;
cout << "Found first word with containing 'w': " << word << endl;
return 0;
}