Solved

Menu Driven Applications

Posted on 2004-04-22
6
407 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Make it loop so that it asks again if there is an invalid choice/
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
This is a short and sweet, but (hopefully) to the point article. There seems to be some fundamental misunderstanding about the function prototype for the "main" function in C and C++, more specifically what type this function should return. I see so…
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now