fork(9) download
  1. #include <cstring>
  2. #include <iostream>
  3. #include<cstdlib>
  4. #include<vector>
  5.  
  6. int main()
  7. {
  8. char input[100] = "102:330:3133:76531:451:000:12:44412";
  9. char *token = std::strtok(input, ":");
  10. std::vector<int> v;
  11.  
  12. while (token != NULL) {
  13. v.push_back( std::strtol( token, NULL, 10 ));
  14. token = std::strtok(NULL, ":");
  15. }
  16.  
  17. for(std::size_t i =0 ; i < v.size() ; ++i)
  18. std::cout << v[i] <<std::endl;
  19. }
Success #stdin #stdout 0s 3472KB
stdin
Standard input is empty
stdout
102
330
3133
76531
451
0
12
44412