fork(11) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <sstream>
  4.  
  5. std::vector<int> split(const std::string &s, char delim) {
  6. std::vector<int> elems;
  7. std::stringstream ss(s);
  8. std::string number;
  9. while(std::getline(ss, number, delim)) {
  10. elems.push_back(std::stoi(number));
  11. }
  12. return elems;
  13. }
  14.  
  15. int main() {
  16. const std::string numbers("102:330:3133:76531:451:000:12:44412");
  17. for (auto i : split(numbers, ':'))
  18. {
  19. std::cout << i << std::endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
102
330
3133
76531
451
0
12
44412