fork(5) download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <string>
  4. #include <vector>
  5.  
  6. std::vector<std::string> SplitWords(std::string s)
  7. {
  8. std::istringstream iss (s);
  9. std::vector<std::string> v;
  10. while(iss >> s)
  11. {
  12. v.push_back(s);
  13. }
  14. return v;
  15. }
  16.  
  17. int main()
  18. {
  19. std::vector<std::string> v {SplitWords("This is a much simpler and more proper version.")};
  20. for(auto const&s : v)
  21. {
  22. std::cout << s << std::endl;
  23. }
  24. }
Success #stdin #stdout 0s 3032KB
stdin
Standard input is empty
stdout
This
is
a
much
simpler
and
more
proper
version.