#include <iostream> // cout
#include <string> // string
#include <sstream> // string stream
using namespace std;
int main()
{
string testString = "Hello how are you.";
istringstream iss(testString); // not istringstream NOT sstringstream
char c; // this will read the delima (space in this case)
string firstWord;
iss>>firstWord>>c; // read the first word and end after the first ' '
cout << "The first word in \"" << testString << "\" is \"" << firstWord << "\""<<endl;
cout << "The rest of the words is \"" <<testString.substr(firstWord.length()+1) << "\""<<endl;
return 0;
}
ICAgICNpbmNsdWRlIDxpb3N0cmVhbT4gIC8vIGNvdXQKICAgICNpbmNsdWRlIDxzdHJpbmc+ICAgLy8gc3RyaW5nCiAgICAjaW5jbHVkZSA8c3N0cmVhbT4gLy8gc3RyaW5nIHN0cmVhbQogICAgdXNpbmcgbmFtZXNwYWNlIHN0ZDsKICAgIAogICAgaW50IG1haW4oKQogICAgewogICAgICAgICBzdHJpbmcgdGVzdFN0cmluZyA9ICJIZWxsbyBob3cgYXJlIHlvdS4iOwogICAgICAgICAKICAgICAgICAgaXN0cmluZ3N0cmVhbSBpc3ModGVzdFN0cmluZyk7IC8vIG5vdCBpc3RyaW5nc3RyZWFtIE5PVCBzc3RyaW5nc3RyZWFtCiAgICAKICAgICAgICAgY2hhciBjOyAvLyB0aGlzIHdpbGwgcmVhZCB0aGUgZGVsaW1hIChzcGFjZSBpbiB0aGlzIGNhc2UpCiAgICAgICAgIHN0cmluZyBmaXJzdFdvcmQ7CgogICAgICAgICBpc3M+PmZpcnN0V29yZD4+YzsgLy8gcmVhZCB0aGUgZmlyc3Qgd29yZCBhbmQgZW5kIGFmdGVyIHRoZSBmaXJzdCAnICcKCiAgICAgICAgY291dCA8PCAiVGhlIGZpcnN0IHdvcmQgaW4gXCIiIDw8IHRlc3RTdHJpbmcgPDwgIlwiIGlzIFwiIiA8PCBmaXJzdFdvcmQgPDwgIlwiIjw8ZW5kbDsKICAgICAgICAKICAgICAgICBjb3V0IDw8ICJUaGUgcmVzdCBvZiB0aGUgd29yZHMgaXMgXCIiIDw8dGVzdFN0cmluZy5zdWJzdHIoZmlyc3RXb3JkLmxlbmd0aCgpKzEpIDw8ICJcIiI8PGVuZGw7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9