I wrote the code below which works in a case of valid input
char input[100];
cin.getline(input, sizeof(input));
stringstream stream(input);
while (stream.rdbuf()->in_avail() != 0) {
int n;
stream >> n;
numbers.push_back(n);
}
but fails when I put something instead of a number. How can I hadle wrong intput(e.g. any letter)?