fork download
  1. #include <string>
  2. #include <sstream>
  3. #include <vector>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. vector<string> myWords;
  9.  
  10. int main()
  11. {
  12. string mySentence, word;
  13. getline(cin, mySentence);
  14. std::istringstream strm(mySentence);
  15. while ( strm >> word)
  16. myWords.push_back(word);
  17.  
  18. for ( auto& v : myWords )
  19. std::cout << v << "\n";
  20. }
Success #stdin #stdout 0s 15240KB
stdin
This is a test
stdout
This
is
a
test