Solved

Menu Driven Applications

Posted on 2004-04-22
6
416 Views
Last Modified: 2010-04-15
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
Comment
Question by:mozzle
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
avizit earned 50 total points
ID: 10891000
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
 
LVL 1

Expert Comment

by:ravenscr98
ID: 10891041
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
 
LVL 9

Assisted Solution

by:ankuratvb
ankuratvb earned 50 total points
ID: 10891057
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
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10891081
Make it loop so that it asks again if there is an invalid choice/
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
This tutorial is posted by Aaron Wojnowski, administrator at SDKExpert.net.  To view more iPhone tutorials, visit www.sdkexpert.net. This is a very simple tutorial on finding the user's current location easily. In this tutorial, you will learn ho…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question