/************************** ** menu.c ** ** Dennis L. Frey ** 11/11/98 ** ** a sample program for menus ** *****************************/ #include /* menu choices */ #define QUIT 1 #define NAME 2 #define ADDRESS 3 #define PHONE 4 main ( ) { int option; /* print the menu options */ printf ("\n"); printf ("Menu selections: \n"); printf ("\t%d. Quit\n", QUIT); printf ("\t%d. Print my name\n", NAME); printf ("\t%d. Print my office number\n", ADDRESS); printf ("\t%d. Print my phone number\n", PHONE); /* now get the option selected */ printf ("Enter your selection: "); scanf ("%d", &option); /* keep asking until the user enters "quit" */ while (option != QUIT) { switch (option) { case NAME: printf ("My name is Bob.\n"); break; case ADDRESS: printf ("My office is 1600 Pennsylvania Ave\n"); break; case PHONE: printf ("My phone is 1-800-555-1212\n"); break; default: printf ("Invalid choice, please try again\n"); break; } /* now get the next choice */ printf ("Enter your selection: "); scanf ("%d", &option); } /* we are done, so say good-bye */ printf ("So long...\n"); }