I'm writing a program for school and I am having a weird problem. It's a menu driven program which allows the user make choices, do what is involved in the choice, then return to the main menu and make another choice. Each choice coincides with opening a certain input file and reading into some global variables.
My problem is when I run any choice from scratch, i.e. it's the first choice, the program runs fine, when I come back to the main menu and make another selection, the input file does not get read correctly. I have attached the code that is relevant to my problem. If anyone can help me I would really appreciate it. If you need more explanation or more info I'd be happy to put it up.
I've checked to see if the file does not get opened properly and also if there is a read error, but there is neither. When I print out the variables after the second choice is made all the variables remain the same accept that the "alph" array is empty. I can't make heads or tails of it. It just seems that the variables are not being touched the second time around.
In a nutshell, the program should prompt the user for a choice, open the file corresponding to the choice and read in the variables, then perform the checkstr() function. When returning from checkstr() it will break from the switch and then theoretically start over since it's do_while(true). The theoretically is where the problem is.
Thanks in advance.
using namespace std;
//HANDLE hConsole = GetStdHandle ( STD_OUTPUT_HANDLE );
cin >> menu_ch;
file_path = "notripcd.txt";
file_path = "decdiv25.txt";
file_path = "genome.txt";
cout << "\nPlease enter the path of your file: ";
cin >> file_path;
cout << "\n\tInvalid entry please try again!!\n\n\t";
cout << "Error reading file!";
my_input_file >> start_st >> no_fin_sts;
my_input_file >> fin_sts[i];
my_input_file >> alph >> no_rows >> no_cols;
my_input_file >> tran_table[i][j];