-
Organiser
I need to create a menu that contains the following entries. I am creating a 'text-based' menu driven Electronic Organiser.
1) The Menu:
Menu structure contains these entries:
- Create an entry
- Amend/Delete an entry
- Search for an entry
- Create mobile phone transfer file
- Quit Application
Thanks.... any suggestions on how to do this, would be appreciated greatly.....
-
What bit are you having trouble with? Post the code you've tried so far, and explain where you're having troubles and someone will help you.
-
That's the problem, I want to create a personal Electronic Organiser and I am a raw novice in C Programming. I have been learning Programming for around 3 weeks, I don't know which functions I need to use? Obviously printf and scanf functions, but I don't know how to write this code to do this.... I don't want full help, I just want ideas and maybe small parts of code to assist me....
Thanks........
-
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.
-
>>I have been learning Programming for around 3 weeks
Code:
void (*jump_menu[4]) ( void ) = {
create_entry,
update_entry,
search_entry,
create_transfer,
};
Function pointer arrays, you meany?! ;) Sorry, got to highlight that one :D But hopefully Socrates will get the jist of what's going on...
-
Thanks very much for helping me out.... Its appreciated....
-
>But hopefully Socrates will get the jist of what's going on...
The jist being to search the boards for more suitable code. ;)
-
Yeah, I know that's a pointer array function. Its cool, heh.... hopefully I'll get all this in the next few months.... I just have to work out how to actually file process a create an entry now into this organiser.... haha.....