fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <algorithm>
  5. #include <iterator>
  6. #include <vector>
  7. using namespace std;
  8.  
  9. int main() {
  10. vector<string> vs;
  11. string line;
  12. while(getline(cin,line))
  13. {
  14. // the following two line are from
  15. // http://stackoverflow.com/questions/236129/how-to-split-a-string-in-c
  16. istringstream iss(line);
  17. copy(istream_iterator<string>(iss),
  18. istream_iterator<string>(),
  19. back_inserter<vector<string> >(vs));
  20. for(vector<string>::iterator it = vs.begin(), iend = vs.end(); it != iend; ++it)
  21. {
  22. cout << *it << endl;
  23. }
  24. vs.clear();
  25. cout << "=== EOL ===" << endl;
  26. }
  27. return 0;
  28. }
  29.  
Success #stdin #stdout 0s 3440KB
stdin
One two three four five
six seven eight nine ten eleven twelve
stdout
One
two
three
four
five
=== EOL ===
six
seven
eight
nine
ten
eleven
twelve
=== EOL ===