fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. #include <string.h>
  5. #include<vector>
  6. int main ()
  7. {
  8. char str[] ="22/33/44";
  9. char * pch;
  10. cout<<"Splitting string into tokens:\n"<<str;
  11. pch = strtok (str,"/");
  12. vector<int> vec;
  13. while (pch != NULL)
  14. {
  15. int val = atoi(pch);
  16. cout<<" "<<val;
  17. vec.push_back(val);
  18. pch = strtok (NULL, "/");
  19. }
  20. return 0;
  21. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
Splitting string into tokens:
22/33/44   22   33   44