I'm working on a text-based program that is written almost exclusively in functions.
I'm using switch statements for the menu choices. Each case input will call the appropriate function.
So here's an example.
Code:
int main()
{
// options for load_file(), new_file(), and exit()
welcome();
// options for set_name(), set_gender(), save_file(), exit()
main menu();
}
So as you can see. Functions welcome() and main menu(), branch off into smaller functions depending on user input. What I'm trying to figure out is how to allow the user to "back" out to the master functions. So lets say they select load_file() accidentally and want to return to welcome(); Or they select set_gender() and want to return to main_menu();
Would I have to write a loop every time a function branches into another function, or could I simply have the "back" option just re-call the previous function to start over from there?
Also, is there anything wrong or sloppy about using a function based program like this? I'm new to coding, and it seemed like the cleanest way in my mind. I have a pretty nice looking flow chart, but I wouldn't be surprised if it is a completely rookie way to do things.
Thanks!