#include #include using namespace std; int main() { //string phrase {"this, is, a, list, of, words"}; string phrase {""}; // this, is, a, list, of, words // is, a, list, of, words // a, list, of, words // list, of, words // of, words // words // // the ouptut should be // this // is // a // list // of // words // size_t pos; pos = phrase.find(", "); while (pos != string::npos) { cout << phrase.substr(0,pos) << endl; phrase = phrase.substr(pos+2); pos = phrase.find(", "); } if (phrase.size() > 0) { cout << phrase << endl; } return 0; }