I did a program that took command line arguements to run it. I am now trying to do a menu drive program as part of its "improvement." I used,
int main(int argc, char * argv[])
in the original where the arguements were:
char * startCity = argv[1];
char * endCity = argv[2];
in.open(argv[3],ios::in); //<----file name went here
Here is what I did now and I know it is incorrect:
int main(int argc, char * argv[]){
int menuChoice;
string startCity;
string endCity;
string fileName;
ifstream in;
cout<<"Welcome to J.A.C. P2\n"
"\n"
"This program will find the shortest path\n"
"from One city to all other cities if there\n"
"is a connecting node, find the shortest path\n"
"between two cities or find the shortest\n"
"between three or more cities.\n"<<endl;
cout<<"Please make a choice of what you would like to do:\n"<<endl;
cout<<" 1------> Shortest Path between 2 cities.\n"
" 2------> Shortest Path between 3 or more cities.\n"
" 3------> Shortest Path from 1 city to all.\n"
" 9------> Take your ball and go home!\n"<<endl;
cout<<"Waiting on you: "; cin>>menuChoice;
switch (menuChoice) {
case 1:
cout<<"Enter the starting city: ";
cin>>StartCity;
cout<<"\nEnter the ending city: ";
cin>>EndCity;
cout<<"\nEnter the name of the file: ";
cin>> fileName;
break;
Since all of my program is based on char * argv[] How can I convert those into strings OR how can I assign variables to the arguements in order to read them in?
I appreciate all the answers but they seem to be going in the direction I am trying to get away from. The OLD program used command line arguements. How can I do this:
string StartCity = char * argv[1];
string EndCity = char * agrv[2];
string filename = in.open(argv[3],ios::in);
That is what I am trying to do. I am sorry if I did not make myself clear.