Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 14, 2011, 09:32 PM   #1
CsRookie
macrumors newbie
 
Join Date: Apr 2011
C programming, menu?

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
4)Save
5)Exit

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.

Last edited by CsRookie; Apr 14, 2011 at 09:58 PM.
CsRookie is offline   0 Reply With Quote
Old Apr 14, 2011, 09:46 PM   #2
jiminaus
macrumors 65816
 
Join Date: Dec 2010
Location: Sydney
Something like the following pseudo-code:

Code:
Initialize program
Loop
  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
  (etc.)
  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.
jiminaus is offline   0 Reply With Quote
Old Apr 14, 2011, 09:58 PM   #3
CsRookie
Thread Starter
macrumors newbie
 
Join Date: Apr 2011
Quote:
Originally Posted by jiminaus View Post
Something like the following pseudo-code:

Code:
Initialize program
Loop
  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
  (etc.)
  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.
Thanks for the quick response, I thought it may be a loop but wasn't sure. Thank you again
CsRookie is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
'Hue Menu' Controls Philips Hue Lights From the Mac Menu Bar MacRumors Mac Blog Discussion 23 May 29, 2014 08:15 PM
Mac programming should be more like iOS programming. moonman239 Mac Programming 13 Feb 17, 2014 01:37 PM
Apple Menu (Grey Menu) / Finder Takes Too Long to Load (Last 24h) ArmCortexA8 OS X Mavericks (10.9) 0 Jul 21, 2013 08:36 AM
Some icons missing on Desktop Menu Bar, Safari Menu Bar and Finder Menu Bar chroniceater MacBook Air 7 Jan 14, 2013 11:50 AM
(null) menu items in iPhoto Share menu ezhilk OS X 1 Oct 7, 2012 08:24 AM

Forum Jump

All times are GMT -5. The time now is 07:30 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC