#include #include using namespace std; int main() { string source {"this is a test this is only a test"}; size_t foundPos; size_t startPos{0}; string word; foundPos = source.find(' '); while (foundPos != string::npos) { word = source.substr(startPos, foundPos - startPos); if (word.size() > 0) { cout << "The word is \"" << word << "\"" << endl; } startPos = foundPos + 1; foundPos = source.find(' ', foundPos+1); } word = source.substr(startPos); cout << "The word is \"" << word << "\"" << endl; return 0; }