fork(5) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <sstream>
  5.  
  6. int main() {
  7. std::string sentence;
  8. std::cout << "Enter a sentence please: "; std::cout.flush();
  9.  
  10. std::getline(std::cin,sentence);
  11. std::istringstream iss(sentence);
  12.  
  13. std::vector<std::string> words;
  14. std::string word;
  15. while(iss >> word) {
  16. words.push_back(word);
  17. }
  18.  
  19. for(std::vector<std::string>::const_iterator it = words.begin();
  20. it != words.end();
  21. ++it) {
  22. std::cout << *it << ' ';
  23. }
  24. std::cout << std::endl; return 0;
  25. }
Success #stdin #stdout 0s 3280KB
stdin
The quick brown fox jumps over the lazy dog
stdout
Enter a sentence please: The quick brown fox jumps over the lazy dog