So basically I have:
// FUNCTION
double function(yadee_yada)
if (input < 0)
{
return 0;
}
else {
return something;
//code
}
// END FUNCTION
//MAIN
int main
{
int menu;
int input;
do {
cout << "Press 1, 2 or 3 (3=quit program).";
cin >> menu;
switch (menu)
{
case 1:
cout << "input 1-5.";
cin >> input;
//CALL FUNCTION (based on "input")
break;
case 2:
//CODE FOR MENU OPTION 2
case 3:
return 0; //QUIT
}
}while(menu != 3)
return 0;
Hope that makes sense. I can post the real code if neeeed be, but I feel like I have a pretty basic question. So when you hit a "break" in one of the switch statements, it goes back to the main menu where you pick option 1, 2, or 3. I want to be able to go to that same menu from within the called function in case the input is less than 0. I tried "return 0;", but it literally just returns the numerical value "0". I tried "break;", but it said I can only use breaks in loops and switch statements. :[
Is there a way to get back to that menu in "main" from a function without putting code in main itself? Thanks!