fork(22) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main()
  5. {
  6. std::string str = "Hello, everyone! This is: COSC-1436, SP18";
  7. std::string const delims{ " .,:;!?" };
  8.  
  9. size_t beg, pos = 0;
  10. while ((beg = str.find_first_not_of(delims, pos)) != std::string::npos)
  11. {
  12. pos = str.find_first_of(delims, beg + 1);
  13. std::cout << str.substr(beg, pos - beg) << std::endl;
  14. }
  15.  
  16. return 0;
  17. }
Success #stdin #stdout 0s 4556KB
stdin
Standard input is empty
stdout
Hello
everyone
This
is
COSC-1436
SP18