What is wrong with this. Everything is working except the first element if the first element contains any zero. e.g. input -> 100 output -> 10 input->6030 output->630.
Question:
Input Format
The first and only line consists of n integers separated by commas.
Output Format
Print the integers after parsing it.
Code:
#include <sstream>
#include <vector>
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> parseInts(string str) {
// Complete this function
stringstream ss(str);
char ch;
vector<int> v;
int s;
int i = 0;
ss >> ch;
cout << ch;
while(ss >> i){
v.push_back(i);
ss >> ch;
}
return v;
}
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;
}