You are viewing a single comment's thread. Return to all comments →
#include <sstream> #include <vector> #include <iostream> using namespace std; vector<int> parseInts(string str) { stringstream ss(str); char comma; int number; vector<int> temporary_vector; for (int i = 0; i < str.size(); ++i) { if (ss >> number) temporary_vector.push_back(number); ss >> comma; } return temporary_vector; } int main() { string str; cin >> str; vector<int> integers = parseInts(str); for(int i = 0; i < integers.size(); i++) { cout << integers[i] << "\n"; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
StringStream
You are viewing a single comment's thread. Return to all comments →