Why don't you create a string variable (character array), accept the input initially into it, verify that the array consists of digits or spaces only. If it contains any other symbol, you know that an error has occured (the data is invalid).
Code:
int validate(char *);
int validate(char *p)
{
while(*p)
{
if(! ((*p >= '0' && *p <= '9') || *p == ' ') )
return 0;
p++;
}
return 1;
}
If we assume that your array name is "inputval" then you could use this function in this fashion
Code:
if( validate(inputval) )
{
std::cout << "Valid input... proceed with converting the character values into integers";
}
else
{
std::cout << "Invalid Input";
}