Program problem

i want to create a program in which when i give any abrivation like TCP so it gives Transmission control protocol............in C++...i work in borland c++
Reposting won't get you an answer either.... show some effort first.
#include<iostream.h>
#include<conio.h>
void main(void)
{
int choice;
clrscr( );
cout << "enter your choice ";
cout << "\n1 ====> FTP\n2 ====> HTTP";
cout << "\n3 ====> DLD\n4 ====> OOP";
cout << "\n5 ====> LAN\n6 ====> WAN";
cout << "\n7 ====> SAD\n8 ====> IP";
cout << "\n9 ====> SPM\n";
cin >> choice;
switch(choice)
{
case 1:
cout <<"File Transfer Protocol";
break;
case 2:
cout <<"Hyper Text Transfer Protocol";
break;
case 3:
cout <<"Digital Logic Design"
break;
case 4:
cout <<"Object Oriented Programming"
break;
case 5:
cout <<"Local Area Network";
break;
case 6:
cout <<"Wide Area Network"
break;
case 7:
cout <<"Software Analysis Design";
break;
case 8:
cout <<"Internet Protocol"
break;
case 9:
cout <<"Software Project Management";
break;
default:
cout<<"Invalid Selection";
}
getch( );
}


i have created it but gives error
::sigh:: I guess this counts. A couple of things to start with.

1. Stop using Borland C++ and switch to MS Visual C++ Express.
2.
1
2
#include<iostream.h>
#include<conio.h> 


Don't need conio, and it should be #include <iostream> not #include <iostream.h>

3. There are several cout statements in your switch that do not end with a semi colon.

4. int main, not void main, and your program should end in return 0;

Start there.

yes but now in dat program i have to run it several times and instead of giving 1,2,3 in choices i have to give naes abrivatoins like TCP,SAD
cin.getLine(std::string);

Then store your results in a map
1
2
3
4
5
6
7
8
map<std::string, std::string> combinations;
combinations["TCP"] = "Transmission Control Protocol";

if (combinations.find(userInput) == combinations.end()) {
 cout << "Please enter valid Abbr" << endl;
} else {
 cout << combinations[userInput] << endl;
}


While this code isn't complete. It should definitely give you something to work from.
map<std::string, std::string> combinations;
combinations["TCP"] = "Transmission Control Protocol";


Actually I don't recommend direct assign. What if combinations["TCP"] already exist? I would silently overwrite it with a new value. If that is the intention it is fine but most of the times, we want to know if an element exist before we try to over-write or create a new entry.

Different developer mileage varies so I guess above is practiced commonly also :)
Topic archived. No new replies allowed.