I am writing a program that starts by printing a menu. The user then picks 1-6 from the options. If they pick 1, it should print an addition problem using two random integers. If they answer "-1" to the problem, the main menu should reprint, giving them the option to choose a different menu option. I have it working almost perfectly, except when they type "-1" to bring the menu back up, it appears as expected... BUT when they enter their new menu choice, the program ends, instead of bringing them to the menu choice they selected. Any help would be very appreciated!
I think I found an easy solution, but I have a question.
Is it wrong to call main() in other parts of your code? Could this cause issues or it is the same as calling any other function? If I simply adjust the if statement from:
if (guess == -1)
{
printMenu();
}
to:
if (guess == -1)
{
main();
}
it works perfectly! Is this a good solution or is it bad habit to call main?