fork(2) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5. const std::string s = "quick \t\t brown \t fox jumps over the\nlazy dog";
  6. const std::string ws = " \t\r\n";
  7. std::size_t pos = 0;
  8. while (pos != s.size()) {
  9. std::size_t from = s.find_first_not_of(ws, pos);
  10. if (from == std::string::npos) {
  11. break;
  12. }
  13. std::size_t to = s.find_first_of(ws, from+1);
  14. if (to == std::string::npos) {
  15. to = s.size();
  16. }
  17. std::cout << "'";
  18. for (std::size_t i = from ; i != to ; i++) {
  19. std::cout << s[i];
  20. }
  21. std::cout << "'" << std::endl;
  22. pos = to;
  23. }
  24. return 0;
  25. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
'quick'
'brown'
'fox'
'jumps'
'over'
'the'
'lazy'
'dog'