Win32 console menu system

Discussion in 'Software' started by snerd, Feb 24, 2011.

  1. snerd

    snerd Private E-2

    Hello.

    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?
     
  2. PC-XT

    PC-XT Master Sergeant

    You could have a delay before going to the select. If another key is typed before the delay is over, it adjusts the variable. For instance, multiplies by 10, then adds the new char. If x is typed, there is no need to delay. If x is typed in the delay, it should return x.

    Using a string might be simpler.
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds