I have a program that USED to take command line arguments and now I am trying to add a user menu instead.
Code:
int menuChoice;
string start;
string end;
string fileName;
ifstream in;
switch (menuChoice) {
case 1:
cout<<"Enter the starting city: ";
cin>>start;
cout<<"\nEnter the ending city: ";
cin>>end;
cout<<"\nEnter the name of the file: ";
cin>> fileName;
break;
In the old code I had this:
Code:
char * StartCity = argv[1];
char * EndCity = argv[2];
in.open(argv[3],ios::in)
I know this:
Code:
char * StartCity = start //start is a string in the menu
char * EndCity = end //end is a string in the menu
Does not work.
I think this does
Code:
file.open (fileName.c_str(), ios::in);
The reason is throughout the program I test the argv's like:
Code:
bool ArgCheck = TestArgs(argv[1],cities,st);
if(!ArgCheck) {
throw MyException("Start city not found in map file.");
}
and I also have functions that use char * like:
Code:
void StackCities(char * StartCity, char * EndCity,...); //<---part of a function
Can someone show me how I can assign those string names in the menu to the argv[1], argv[2] and argv[3]?