Hi all,
Everytime i have made a program and received an input from the user, such as:
int choice;
cout << " Please enter 1 for addition or 2 for subtraction.\n";
cin >> option;
if the user's input is not a number like say for example the user decides to press a letter iinstead of a number, the program would go into an infinite loop. Is there any way of preventing an error such as this?
Thanks,
Greg
Everytime i have made a program and received an input from the user, such as:
int choice;
cout << " Please enter 1 for addition or 2 for subtraction.\n";
cin >> option;
if the user's input is not a number like say for example the user decides to press a letter iinstead of a number, the program would go into an infinite loop. Is there any way of preventing an error such as this?
Thanks,
Greg