I am attempting to develop a win32 console menu system using VC++ 2010 under some specific parameters: It gives the user an option to choose 1 through 20, or push x to exit. I attempted to receive input from the user using a char variable and using cin >>, and processing the input with a switch statement (Case 1 thru Case 20, Case x). I discovered that if the user inputed a double digit number, 10 for example, the switch statement would process case 1 and case 0. I can't switch the input variable to an int because it won't store anything in the variable if the user selects "x". The menu system has to fit the parameters I stated above, so my question is: is there a way to setup the menu with a char variable that will process the input as '10' rather than '1' and '0'? Or to translate "x" into it's ASCII value before it's passed to the int variable? Or is using a string my only option for this setup?
I want the user to be able to choose a number between 1-20, but if the user enters a double digit number, 14 for example, the program will execute case 1 and case 4. What can I do to get the program to process the input as case 14 instead of case 1 and 4?