Hi,
I'm looking for ways to interact with different arrays depending on user input. I have different lists of menu items that can be shown on a small LCD screen depending on where the user is navigating. So, for example, while you're in the navigation menu, you'd see only menu items related to navigation. Then, when you select another menu, the interface is refreshed and new menu items are shown.
My first thought was to create a generic function that accepts an array as an argument and that displays the chars contained in this array. But this seemed not possible since different menus might differ in the number of items they offer.
Secondly, I thought I could have a variable that holds a reference to the currently active menu, but that seemed impossible for the same reason as above. For example:
char *navigationMenuItems[] = {"Previous", "Current", "Next"};
char *settingsMenuItems[] = {"Volume", "Controls", "Brightness", ...}
currentMenu = settingsMenuItems
Lastly, I tried creating an array that contained all the other menu item arrays like so:
char *navigationMenuItems[] = {"Previous", "Current", "Next"};
char *settingsMenuItems[] = {"Volume", "Controls", "Brightness", ...}
char **allMenus[][] = {navigationMenuItems, settingsMenuItems};
But again, the compiler would not let me run this, no matter what I tried.
Any ideas here? I'm coming from a web dev perspective and this way of dealing with data is very foreign to me.
Thank you!