extract input from keyboard
Posted on 2003-03-20
Suppose I have a program in C++ that need to obtain user's choice such as following:
a. open account;
b. update account;
c. delete account;
Please select (a, b, c or x then press enter):
My question is how can I ask user to re-enter selection if s/he accidently press enter key in stead of any one of the choice key?
The system should remind the user to re-select such as "It is not a choice please re-select: ". Also what function should be used? I tried to use such as "cin.get(selection)" but cannot get rid of the newline character that is created by pressing the enter key after selected a, b, c or d.