Code:
/* Warning: This code is from memory and untested */
#include <stdio.h>
int menu ( void );
void create_entry ( void ) { puts ( "create entry" ); }
void update_entry ( void ) { puts ( "update/delete entry" ); }
void search_entry ( void ) { puts ( "search entry" ); }
void create_transfer ( void ) { puts ( "create transfer file" ); }
int main ( void )
{
void (*jump_menu[4]) ( void ) = {
create_entry,
update_entry,
search_entry,
create_transfer,
};
int option;
while ( ( option = menu() ) != 5 ) {
if ( option < 1 || option >= 5 ) {
printf ( "Blah, bad choice\n" );
}
else {
jump_menu[option - 1]();
}
}
return 0;
}
int menu ( void )
{
int option;
printf ( "1) Create an entry\n"
"2) Amend/Delete an entry\n"
"3) Search for an entry\n"
"4) Create mobile phone transfer file\n"
"5) Quit Application\n"
":> ");
scanf ( "%d", &option );
return option;
}
Or you could search the boards. This question is asked at least once a week.