Try this:
Code:
#include <stdio.h>
int get_menu_choice (void);
int main ()
{
int choice;
choice = get_menu_choice();
printf("you chose menu option %d\n", choice);
return 0;
}
int get_menu_choice (void)
{
int selection;
do
{
printf("\n");
printf("\n1 - add record");
printf("\n2 - change record");
printf("\n3 - Delete a record");
printf("\n4 - Quit");
printf("\n");
printf("\nEnter a selection: ");
scanf("%d", &selection);
while ( getchar() != '\n' ); /* Clear the input buffer */
}
while (selection < 1 || 4 < selection );
return selection;
}
-Prelude