Background:
I need the user to type in an int "k" key for an encryption program. For the program to work right, the user entered int needs to be between 1-25. It can't be higher. The problem is if the user enters something other than an int, the program either just continues, or the program goes into an infinite loop. The int "t" just acts as a true/false for the loop.
do
{
t=1;
cout << "\nEnter the encryption key (1-25): ";
cin >> k;
if ((k<1)||(k>25))
{
cout << "\nERROR: Enter a valid number moron!\n";
t=0;
}
}
while (!t);
I tried converting the value to a tmp char and checking the char to be between SOH-EM, but that results in the same problems.
Any help greatly appreciated :cheesy: Btw, its my first post, I think.