int main(void)
{
int valid_input();
int ll_input=0;
int resp;
hash_table obj;
int bucket;
while(1)
{
ll_input=valid_input();
if(ll_input>10)
{
break;
}
obj.insert(ll_input);
}
obj.print_ll();
return 0;
}
int valid_input()
{
int input;
printf("\n\rEnter the value: ");
std::cin >> input;
while(std::cin.fail())
{
std::cin.clear();
std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n');
printf("\n\rBad entry!\n\rEnter the value: ");
std::cin>>input;
}
return input;
}
The above is the code, it works correctly for most alphanumeric combinations, it rejects user inputs like a,10aa,1003abc, etc. However, it on inputs like 100a, 100b, etc, passes. What could the reason be for this?