fork download
  1. #include <iostream>
  2. #include <list>
  3. #include <string>
  4. using namespace std;
  5.  
  6. ostream &operator << (ostream &oss, list<string> &lst) {
  7. for (auto &w : lst) {
  8. oss << w << endl;
  9. }
  10. return oss;
  11. }
  12.  
  13. int main() {
  14. string words;
  15. list<string> LolWords;
  16. cout << "Enter any words in the order you would like"
  17. << endl << "them displayed" << endl;
  18. cout << endl << "Enter 1 to quit" << endl << endl;
  19.  
  20. while (getline(cin, words) && words[0] != '1')
  21. LolWords.push_back(words);
  22.  
  23. cout << LolWords << endl;
  24. return 0;
  25. }
Success #stdin #stdout 0s 3436KB
stdin
Hello
World
How
Is
It
Going
1
stdout
Enter any words in the order you would like
them displayed

Enter 1 to quit

Hello
World
How
Is
It
Going