Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 435
  • Last Modified:

Menu Driven Applications

Hi

Being generally disorganised and now panicing, I would appreciate any help to get me moving:

I have a c programming problem which has to be menu driven. Must accept data to a named file, save, read, sort and perform various actions upon this data held. When selected from the menu.

Problem is i have only done basic programms and for the above, I haven't a clue were to start. Any help will be gratefully recieved.

Cheers  Mozzle

0
mozzle
Asked:
mozzle
  • 2
2 Solutions
 
avizitCommented:
I presume you have to make a text based menu

well to begin with first

1.you have to  present the menu to the user
for that use printf () (or puts() ) to output something on the screen say

##### what is your name ?

2. now you have to get the user input for that you use

scanf() ( or gets() as the case maybe )

3. after you have read the user input you can base your further action depending on the input

for example like

if (inout == 'd' ){

 // delete action
}else if (inout == 'q'){
 //quit action  

etc etc

hope it helps . to get you started .

come back if you after you have started and face more problems.

/abhijit/
0
 
ravenscr98Commented:
Sounds like a panicked homework problem.  We cannot give code, but we can give lots of advice.

First, you need to clarify what you mean by menu system.  Are you supposed to use a GUI system such as Windows or gnome?  Or are you supposed to print a list of options, have the user enter their choice, then process it? There's too many options for "menu system" to give you any advice.
0
 
ankuratvbCommented:
use switch..case along with getchar() to get the choice.

If you are using Borland's compilers,you can use getch() for getting user input.

char ch;
printf("1..");
printf("2..");
printf("3..");
printf("4..");
ch=getchar();//or ch=getch();
switch(ch)
{
 case '1'://do something
              break;
 case '2'://do something
              break;
 case '3'://do something
              break;
 case '4'://do something
              break;

 default:printf("Invalid choice");
             break;

}
0
 
ankuratvbCommented:
Make it loop so that it asks again if there is an invalid choice/
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now