If the program is expecting an integer (a number) but the user enters a letter, then the cin.fail() flag will be set. In order to fix that, you would need to both clear the error flags and empty the input buffer.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
if (!(cin >> choice))
cin.clear(); // reset the error flags
cin.ignore(1000, '\n'); // remove up to 1000 characters
// or until newline is found, from input buffer.
But, you can avoid the need to worry about that if the input is read as a character instead of an integer.
takes character values meaning a-z, 0-9, and symbols.
choosing which one to use is a matter of taste, and how to test if you want numbers only you can always use other functions like isDigit or isAlpha and throw and error if not the one you want.
The program freezes because it does not recognize the input and does not know what to do there on. unless you tell it to ignore what was input like Chervil did at the top, then it will continue as normal.