fork(1) download
  1. #include <iostream>
  2. #include <string>
  3. #include <sstream>
  4. #include <vector>
  5. using namespace std;
  6. vector<int> parseInts(string str)
  7. {
  8. stringstream ss(str);
  9. string token;
  10. vector<int> v;
  11. while (getline(ss, token, ',')) {
  12. int x = stoi(token);
  13. v.push_back(x);
  14. }
  15.  
  16. return v;
  17. }
  18. int main() {
  19. // your code goes here
  20. for (int x : parseInts("33,44,55")) {
  21. cout << x << endl;
  22. }
  23. return 0;
  24. }
Success #stdin #stdout 0s 4200KB
stdin
Standard input is empty
stdout
33
44
55