fork download
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. int main()
  5. {
  6. std::string s = "first second third fourth fifth sixth";
  7. for (char* tmp = std::strtok(&s[0], " "); tmp;
  8. tmp = std::strtok(nullptr, " "))
  9. {
  10. std::string s(tmp); // can "<< tmp <<" below directly....
  11. std::cout << "S " << s << '\n';
  12. }
  13. }
Success #stdin #stdout 0s 3272KB
stdin
Standard input is empty
stdout
S first
S second
S third
S fourth
S fifth
S sixth