Menus in cmd

closed account (42hU7k9E)
I am trying to make a menu in cmd, and I have no idea where to start?
What exactly do you want?

If you mean a console application with a menu where you can click on a option to choose: i dont believe that's possible (in a console), or maybe it is, but then it's really difficult.

You could use someting like this:

--------------------------------------------
What would you like to do?

[1] Option one
[2] Option two
[3] Option three
--------------------------------------------


And then ask the user for input, and use if/else statements or a switch to call the right function. Switch is shorter and clearer, but you need the input in a integer variable, and it gives problems when you store userinput directly into a integer (if the user enters a char the program will crash if you havent do anyting to avoid that). You could use strtol(). http://www.cplusplus.com/reference/clibrary/cstdlib/strtol.html
Last edited on
For switching, I use string and getline. It's a little bit saver, since string can hold almost anything you typed.

Also, you don't have to bother about the newline leftover.
Last edited on
On my compiler (dev-cpp) I can only use integer as argument for a switch. If I use another datatype, I get this error:
switch quantity not an integer

I believe thats the standard, according to the ISO. Wich compiler do you use?
Topic archived. No new replies allowed.