Hello everyone, thanks for looking. I'll get right to the point: I'm having problems trying to figure out a hierarchy of menus in C; command-line style.
Say, for example the program analyzes a file of names/letters to figure out the patterns of letters within the names. The user should be able to do many things with the information such as add names, delete names, and add new letters (a letter is defined as any subset of a group of consonants or vowels) just to name a few.
I have all the underlying functions done (successfully analyzing the file various ways and saving the info).
The main problem I have is that I don't want the user to be able to navigate the menus in a way that it places a ton of menus on the stack.
An ideal use case stack would look like this:
Main Menu
--Names Database Menu
----Sort Names Menu
------Sort Names by length function
------(Original Sort Names Database removed from function stack)
----Sort Names Menu
----*Return to Main Menu option*
----(Original Names Database Menu removed from function stack
----(Second Sort Names Menu removed from function stack)
Main Menu
The problem I'm having is to figure out an intuitive method that would avoid a situation that has the potential to create a huge stack like this:
Main Menu
--Names Database Menu
----Sort Names Menu
------Sort Names by length function
----Sort Names Menu
------*Return to Main Menu Option chosen*
------Main Menu
--------etc, etc
I'm wondering if I should have an array of function pointers for each menu available (which is a lot) or if I should have different switch functions for each menu display function, or the other 6 options I can think of that I can't seem to work an easily understandable bit of pseudocode for.
Any help at all would be appreciated... I don't need working code. I'm just not sure how menus are really done in the real world and figured it would be an easy suggestion from those more experienced.