Resolved C programming, menu?

Discussion in 'Mac Programming' started by CsRookie, Apr 14, 2011.

  1. CsRookie, Apr 14, 2011
    Last edited: Apr 14, 2011

    CsRookie macrumors newbie

    Apr 13, 2011
    How would one go about creating a menu for a c program? The menu would allow the user to select where they want to go in the program. For example:

    1)View Inventory
    2)Add Inventory
    3)Remove Inventory

    Something along those lines and the user would input 1-5 and then it would take them to the next part of the program. How would a menu driven program work? I tried the search but no luck, any links to examples or simple explanation would be greatly appreciated. :apple:
  2. jiminaus macrumors 65816


    Dec 16, 2010
    Something like the following pseudo-code:

    Initialize program
      Print menu on screen
      Read menu choice from keyboard
      If menu choice is 1 then do view inventory
      If menu choice is 2 then do add inventory
      If menu choice is 5 then exit loop
    End loop
    Cleanup program
    In terms of implementing this, you'd probably do this all in main, and define separate functions to implement "do view inventory", "do add inventory", etc.
  3. CsRookie thread starter macrumors newbie

    Apr 13, 2011
    Thanks for the quick response, I thought it may be a loop but wasn't sure. Thank you again :apple:

Share This Page