fork download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string sentence = "hello,potato tomato.";
  7. std::string delims = " .,";
  8.  
  9. size_t beg, pos = 0;
  10. while ((beg = sentence.find_first_not_of(delims, pos)) != std::string::npos)
  11. {
  12. pos = sentence.find_first_of(delims, beg + 1);
  13. std::cout << sentence.substr(beg, pos - beg) << std::endl;
  14. }
  15. }
Success #stdin #stdout 0s 4512KB
stdin
Standard input is empty
stdout
hello
potato
tomato