fork(4) download
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <iterator>
  4. #include <string>
  5. #include <vector>
  6.  
  7. using namespace std;
  8.  
  9. int main() {
  10. auto str = "The quick brown fox"s;
  11. auto start = find(cbegin(str), cend(str), ' ');
  12. vector<string> tokens{ string(cbegin(str), start) };
  13.  
  14. while (start != cend(str)) {
  15. const auto finish = find(++start, cend(str), ' ');
  16.  
  17. tokens.push_back(string(start, finish));
  18. start = finish;
  19. }
  20.  
  21. copy(cbegin(tokens), cend(tokens), ostream_iterator<string>(cout, "\n"));
  22. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
The
quick
brown
fox