system crash when char is entered during int switch? solution?
i noticed when i have a switch statement the default does not catch chars...
here is a sample-
Code:
int input;
cin>>input;
switch(input)
{
case 1:
statement;
break;
case 2:
statement;
break;
case 3:
statement;
break;
default:
cout<<"cant do that\n";
break;
}
im guessing this is because the switch statement is only taking ints, but is there a way I can prevent a system crash if myself or someone accidentally inputs a char rather than an int?