Alright guys, I just want to know if this is possible.
Honestly beginner in messing with code so I thought I'd ask. Pic related is the program. All I want to do is create a menu that adds more options (easy) like input temperature, but what I really want to do is take from the user a new compound of their choosing and its boiling/freezing points and display that in the columns with the already extant compounds
>tl,dr; add new cout statements for successive user input, what techniques use
Just create a true while loop to print your options and inside it use a switch to control what functions are run depending on which menu option is selected. Have it break from the loop when the user decides to exit
>>58823034
>true while loop to print your options
>use a switch to control what functions are run depending on which menu option
Thanks. I've done both before so that should be easy enough, just set a do/while and have a char-based switch or whatever.
But really is there anyway to print infinite cout statements for as long as the user enters new compounds? They enter one, it displays four, they enter one in the next loop, it displays five, etc. Something something array?
Yea you can have a function do a while loop as mentioned and just quit exit that loop when inputting something specific. i.e. Q
>>58823199
This is some sort of meme that I'm unaware of, isn't it?
Fuck. I guess the only answer is for me to lurk more, or alternatively fuck off to stack exchange
>>58823674
not even meming you, kid.
L2Implement event handler loopsint printMenu(){
cout << "This is my Menu!\n1. Option 1\n2. Option 2.......... \n(q)uit\nSelection : ";
int selection;
cin >> selection;
if (selection == 113 || selection == 81) return -1; // Return - 1 if ascii for q
if (selection < 1 || selection > #NUMOPTIONS) { cout << selection << " is an invalid selction.\n"; return printMenu();}
return selection;
}
int main(){
while (true) {
int choice = printMenu();
switch (choice){
case 1:
doFunction1();
case 2:
doFunction2();
case 3:
etc();
default: //if choice == -1
return; //quit
}
}
>>58823817
forgot my break statements in the switch, but you get the point
>>58823817
that is not event handling, lmao
>>58824287
>waits for a keyboard event after printing menu
>handles said event
It's event handling at it's simplest form
>>58824303
No that event, but giving it the name 'event handling' is misleading because anon might get more experienced and find out that event handling has a different meaning in most cases.
>>58824756
Not that anon* damn it.