LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-10-2004, 05:39 AM   #1
bg2300
LQ Newbie
 
Registered: Mar 2004
Distribution: SuSE 9.0 Professional
Posts: 3

Rep: Reputation: 0
creating menu with c++


I am a newbie c++ programmer. I created a simple numbered menu, i get the users choice and based on that choice it calls the appropriate function. Once that function completes the program ends. I want it to reload the menu after the function finishes. How would i do this? The menu is in main(). I tried using a do loop to reload the menu when the function returns control to main but when the user enters the q to quit the programme goes into an infinite loop. Please help.
 
Old 07-10-2004, 06:24 AM   #2
kev82
Senior Member
 
Registered: Apr 2003
Location: Lancaster, England
Distribution: Debian Etch, OS X 10.4
Posts: 1,263

Rep: Reputation: 51
cant do a great deal without seeing your code
 
Old 07-10-2004, 11:08 PM   #3
gizmo_thunder
Member
 
Registered: Apr 2004
Posts: 101

Rep: Reputation: 15
int main( )
{
LABEL:
int choice = drawMenu( );
switch(choice)
{
case 1:
//do something.
goto LABEL;
case 2:
//do something...
goto LABEL;
case 3: //suppose this is exit
break;
}
return 0;
}

I think this should do it
 
Old 07-11-2004, 01:18 AM   #4
AquamaN
Member
 
Registered: Oct 2002
Location: Ohio, USA
Distribution: OS X 10.4.8, Ubuntu 6.10
Posts: 146

Rep: Reputation: 15
it's late and i may have misread your post, but you could do something like this.

Code:
int main()
{
     char choice;
     //put your choices here
     cout << "CHOICE GOES HERE" << endl;
     cin >> choice;

     //now you can just do a while until the user puts in a 'q'

     while (choice != "q")
     {
           if (choice == "a")
           {
                 //whatever you want to do
            }
           //do that same thing for all
       
           //now just do another prompt for choices
           cout << "CHOICES" << endl;
           cin >> choices;
      }
  return 0;
}
hope that helps!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
creating shortcuts in the menu bar neerajchaudhari Linux - Software 2 08-27-2005 12:00 PM
KDE applications menu replaced by Gnome style menu denh0 Mandriva 2 11-24-2003 01:14 AM
Problem while creating MENU ITEM in RedHat 8 KDE and GNOME rameshvl Linux - General 1 04-25-2003 11:06 PM
Problem while creating MENU ITEM in RedHat 8 KDE and GNOME rameshvl Linux - General 2 04-25-2003 05:05 AM
Creating Start Menu Items in RedHat 8.0 KDE and GNOME rameshvl Linux - Software 3 03-17-2003 02:53 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration