|Problems? Is your data what you think it is?|
Re: Printing a subset of a data structureby jdporter (Canon)
|on May 01, 2006 at 16:15 UTC||Need Help??|
I think what you're trying to achieve here (correct me if I'm wrong) is to display a submenu only when it's needed, i.e. if the user has selected an item from the main menu which has a submenu. To do this, you're wanting to defer the printing of a submenu. Your code, as shown, does not acheive this; even though you're taking a reference to the print_sub_menu function, you're still calling it right away, and putting the result in the data structure. Instead, you should put a code reference in the data structure. E.g.:
Then, when the user selects an item, you can execute the action; something like this:
Other than that, there's a lot you could do to this to make it more generic and robust.
Might I also suggest that you're suffering from (or inflicting) Indentation Hell. Try it this way:
We're building the house of the future together.