when i take input as:
8
10,4,74,61,8,37,2,35
i get runtime error.but if i remove 8 from input and cin>>n from code the code is working perfect . How can i take n also as input? example link "https://ideone.com/hr96ef"
#include <iostream>
#include<vector>
#include <string>
#include <sstream>
using namespace std;
int main() {
int n;
cin>>n;
std::string input_str;
std::vector<int> vect;
std::getline( std::cin, input_str );
std::stringstream ss(input_str);
int i;
while (ss >> i)
{
vect.push_back(i);
if (ss.peek() == ',')
ss.ignore();
}
cout<<vect[3];
return 0;
}