You are reading the complete string text (
"1,2,3"
) into
ss
each time, not just a single character. Change the code to the following to see what I mean:
char waste;
int a,b,c;
string input;
cin >> input;
stringstream ss;
ss << input;
cout << "ss: " << ss.str() << endl;
ss >> a;
ss << input;
ss >> waste;
cout << "ss: " << ss.str() << endl;
ss << input;
ss >> b;
ss << input;
ss >> waste;
cout << "ss: " << ss.str() << endl;
ss << input;
ss >> c;
cout << a << endl << b << endl << c << endl;