| kajzec (32) | |
| I am trying to make a menu in cmd, and I have no idea where to start? | |
|
|
|
| Scipio (442) | ||
|
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:
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
|
||
| chu121su12 (31) | |
|
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
|
|
| Scipio (442) | ||
On my compiler (dev-cpp) I can only use integer as argument for a switch. If I use another datatype, I get this error:
I believe thats the standard, according to the ISO. Wich compiler do you use? | ||
|
|
||