fork download
  1. #include <iostream>
  2. #include <iterator>
  3. #include <sstream>
  4. #include <string>
  5. #include <vector>
  6.  
  7. int main ()
  8. {
  9. const char *sz = " this is a test string " ;
  10.  
  11. std::stringstream ss (sz) ;
  12.  
  13. auto begin = std::istream_iterator <std::string> (ss) ;
  14. auto end = std::istream_iterator <std::string> () ;
  15.  
  16. std::vector <std::string> v (begin, end) ;
  17.  
  18. for (std::string &s : v) {
  19. std::cout << s << "\n" ;
  20. }
  21.  
  22. return 0 ;
  23. }
  24.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
this
is
a
test
string