Lost Password?


Go Back   CodeCall Programming Forum > Software Development > C and C++

C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-20-2007, 04:13 AM
Unknown2dark's Avatar   
Unknown2dark Unknown2dark is offline
Newbie
 
Join Date: Apr 2007
Location: Egypt <_< not proud
Age: 17
Posts: 13
Rep Power: 0
Unknown2dark is on a distinguished road
Default A way to combine programs...

I was just wondering, can't i make a program that in the beginning ask me which program i want, something like i have a + Calculator and a - one, so how about if i can make a program that at the beginning says

"Choose the program you want:-

Addition = h
Subtraction = g

Enter the letter of your program:- ...."

Can that happen?
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 04-20-2007, 08:44 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

What do you mean?
Do you want to make some kind of menu in your console application, or are you trying to start up other applications/processes?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-20-2007, 09:58 AM
Unknown2dark's Avatar   
Unknown2dark Unknown2dark is offline
Newbie
 
Join Date: Apr 2007
Location: Egypt <_< not proud
Age: 17
Posts: 13
Rep Power: 0
Unknown2dark is on a distinguished road
Default

Dunno the difference but, i just want when i open the program, instead of only having one function, it can be used for many functions, and that's done by a list in the beginning, is that easier to understand, or not?
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-20-2007, 11:17 AM
v0id's Avatar   
v0id v0id is offline
Retired
 
Join Date: Apr 2007
Location: Denmark
Posts: 2,654
Last Blog:
CherryPy(thon)
Rep Power: 29
v0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of lightv0id is a glorious beacon of light
Send a message via MSN to v0id
Default

Hmm, I think you mean a menu. You've to give the user multiple choices of what to do, right? For example if it's a console-based calculator, you want to have the user to choice between addition, subtraction, etc.

A little example, using switch-statement.
An if-construction could had been used to.
Code:
#include <iostream>

void addition()
{
	int a, b;
	
	std::cout << "Input two numbers. " << std::endl;
	std::cout << " Number 1: ";
	std::cin  >> a;
	std::cout << " Number 2: ";
	std::cin  >> b;
	std::cout << " Result:   " << a+b << std::endl;
}

void subtraction()
{
	int a, b;
	
	std::cout << "Input two numbers. " << std::endl;
	std::cout << " Number 1: ";
	std::cin  >> a;
	std::cout << " Number 2: ";
	std::cin  >> b;
	std::cout << " Result:   " << a-b << std::endl;
}

int main()
{
	char choice = 0;
	
	while(choice != 'Q')
	{
		std::cout << std::endl;
		std::cout << " ---- " << std::endl;
		std::cout << std::endl;
		
		std::cout << "What do you want to do?" << std::endl;
		std::cout << " 1. Addition" << std::endl;
		std::cout << " 2. Subtraction" << std::endl;
		std::cout << " Q. Exit" << std::endl;
		std::cout << ">> ";
		std::cin  >> choice;
		
		switch(choice)
		{
			case '1':
				addition();
				break;
			case '2':
				subtraction();
				break;
			case 'Q':
				break;
			default:
				std::cout << "Invalid option, try again!" << std::endl;
				break;
		}
	}

	return 0;
}
Tell me if that weren't what you meant.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-20-2007, 06:11 PM
Unknown2dark's Avatar   
Unknown2dark Unknown2dark is offline
Newbie
 
Join Date: Apr 2007
Location: Egypt <_< not proud
Age: 17
Posts: 13
Rep Power: 0
Unknown2dark is on a distinguished road
Default

That was just what i want, really many thanks, i will try to figure out how to make my own now, thanks btw, you've been a great help since i joined..
__________________
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows XP Tricks & Tips!!!!..new ones. pranky Tutorials 9 08-23-2008 04:22 PM
What Programs do you use for web design TVDinner Website Design 113 07-17-2008 12:14 PM
my c programs bobwrit C and C++ 4 10-01-2007 09:46 AM
Phone programs Kaabi General Programming 3 07-06-2006 07:10 PM
Making programs for mobile phones Crane General Programming 2 06-26-2006 04:53 PM


All times are GMT -5. The time now is 02:52 AM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads