473,406 Members | 2,387 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Console menu

hi there, could any of you pros help me out on how to start an menu-based console application using C++ functions? I dont think i'd be able to cope with OOD as im still new to c++. Not too sure on how to call out each function from the menu
Apr 18 '07 #1
10 5618
sicarie
4,677 Expert Mod 4TB
hi there, could any of you pros help me out on how to start an menu-based console application using C++ functions? I dont think i'd be able to cope with OOD as im still new to c++. Not too sure on how to call out each function from the menu
Are you looking for something that involves Design Patterns? Is this supposed to be a GUI, or a text-based menu?

We need a bit more to help - how are you trying to call the function from the menu now?
Apr 18 '07 #2
Are you looking for something that involves Design Patterns? Is this supposed to be a GUI, or a text-based menu?

We need a bit more to help - how are you trying to call the function from the menu now?
Thanks for the reply, it's supposed to be a text-based menu. It's supposed to be able to launch functions to find ID's, write new ID's and save new ID's as well.
Apr 18 '07 #3
sicarie
4,677 Expert Mod 4TB
Thanks for the reply, it's supposed to be a text-based menu. It's supposed to be able to launch functions to find ID's, write new ID's and save new ID's as well.
Seems pretty straightforward, what part are you getting stuck on?
Apr 18 '07 #4
Pretty much everything, kinda have no clue on how to code a menu :/
Apr 18 '07 #5
weaknessforcats
9,208 Expert Mod 8TB
Try an infinite loop:

Expand|Select|Wrap|Line Numbers
  1. while (1)
  2. {
  3.       cin >> choice;
  4.       case 1:
  5.           Add(...);
  6.           break;
  7.       case 2:
  8.           Revise(...);
  9.           break;
  10.       case 3:
  11.           Exit();
  12.           return 0;
  13. }
  14.  
Apr 18 '07 #6
sicarie
4,677 Expert Mod 4TB
Pretty much everything, kinda have no clue on how to code a menu :/
Ok, well then, let's start with the basics: do you know how to print stuff out and read variables in?

Do you have your functions created? Do you know how to call them? Have you tested them and know that they work?
Apr 18 '07 #7
ilikepython
844 Expert 512MB
Pretty much everything, kinda have no clue on how to code a menu :/
You can have a series of cout statements that explain the options and then have a number correspond to each option like:
1: first option
2: second option
etc.
then check what number the user entered and perform the correct function.
Apr 18 '07 #8
weaknessforcats
9,208 Expert Mod 8TB
Oops. forgot the switch

Try an infinite loop:

Expand|Select|Wrap|Line Numbers
  1. while (1)
  2. {
  3.       cin >> choice;
  4.       switch(choice)
  5.       {
  6.       case 1:
  7.           Add(...);
  8.           break;
  9.       case 2:
  10.           Revise(...);
  11.           break;
  12.       case 3:
  13.           Exit();
  14.           return 0;
  15.       }
  16. }
  17.  
Apr 18 '07 #9
sicarie
4,677 Expert Mod 4TB
Try an infinite loop:

Expand|Select|Wrap|Line Numbers
  1. while (1)
  2. {
  3.       cin >> choice;
  4.       case 1:
  5.           Add(...);
  6.           break;
  7.       case 2:
  8.           Revise(...);
  9.           break;
  10.       case 3:
  11.           Exit();
  12.           return 0;
  13. }
  14.  
I wouldn't recommend an infinite loop, but that's a personal preference, I don't like break statements. I'd suggest having a sentinel/exit value to check (have one of the cases be 'exit' and set a boolean, so the while will fail).

But as I said, that's personal preference, weaknessforcats' method will certainly work.
Apr 18 '07 #10
Yea most of the functions work, and finally got it done recently. Thanks guys!
Apr 22 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Paul Johnston | last post by:
I'm using VB.Net. I've tried using Console.Read() but it requires a line-terminator before it finishes (doesn't that mean it's functionally equivalent to ReadLine() -- why have it then?). I've...
6
by: Roberto Dias | last post by:
Could anyone give me some tips about how to start a menu-based console application using C++ function oriented programming techniques? I'm a FORTRAN-based electrical engineer and a newbie on C++...
7
by: ajikoe | last post by:
Hello All, It is said that : Enabling the console window is easy. From Microsoft Visual Studio®, right-click on the project and choose Properties. Change the output type from Windows Application...
4
by: Ron | last post by:
Hello, how do you pass args to a console app? class TestApp { static void Main(string args) { // // TODO: Add code to start application here
17
by: MumboJumbo | last post by:
Hi I have a really basic question hopefully some can help me with: Can you write a (i.e. one) C# project that works from the cmd line and gui? I seems if i write a GUI app it can't write to...
15
by: Michael C | last post by:
Is it possible to have an app that is both a console app and a windows app? If there are no command line switches then it will run as a console app, if there are command line switches then it will...
12
by: Dilip | last post by:
Hi All I have a server based C# console application. This application must hide its console window when its launched out on the field. So I dutifully P/Invoke'd FindWindow/ShowWindow...
0
by: Stephen Thomas | last post by:
Hi there I wonder if any one has encountered this problem or can suggest what is wrong. I am trying the a procedure from the msn site but get the following message: Error 1 The type or...
5
by: Dilip | last post by:
I have written a C# based console application. Due to some issues thats been causing me endless nightmares, I was wondering, is there a way to prevent right mousebutton clicks on my application...
5
by: =?Utf-8?B?UGFvbG8=?= | last post by:
I'm learning C# via console apps (to avoid getting bogged down in Windows stuff). I'm wondering how the OO paradigm would work. Say I'm developing 'classic' menu-driven apps where a menu gives a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.