Input one number at a time, and check whether the following character is ,
. If so, discard it.
#include
#include
#include
#include
int main()
{
std::string str = "1,2,3,4,5,6";
std::vector vect;
std::stringstream ss(str);
for (int i; ss >> i;) {
vect.push_back(i);
if (ss.peek() == ',')
ss.ignore();
}
for (std::size_t i = 0; i < vect.size(); i++)
std::cout << vect[i] << std::endl;
}