Input Format
The first and only line consists of n integers separated by commas.
Output Format
Print the integers after parsing it.

P.S.: I/O will be automatically handled. You need to complete the function only.

hackerrank stringstream problem solution in c++ programming

stringstream problem solution in c++ programming | HackerRank

#include <sstream>
#include <vector>
#include <iostream>
using namespace std;

vector<int> parseInts(string str) 
{
stringstream s(str);
vector <int> a;
char ch;
int t;
while(s>>t)
{ a.push_back(t);
s>>ch;}
return a;
}

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;
}