My first problem is if I'm even reading the components of the file into the array correctly. Then I need to display the array like the file with row and column indicators. I thought I was close but I can't get the indicators to display properly and the contents of the array don't seem to be displaying properly. I'm still new to c++ so this has been difficult for me.
Here's the input file:
X X X X X
X X X X X
X X X X X
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O O O O
O O A A A
O O A A O
O A A O O
X X X X X
O O O O O
O A A O O
O A A O O
O O A O O
O A O O O
O O A O O
O A O O O
O O A A A
O O O O O
O O O O O
A A A A O
O A O O O
A A A A A
A A A A A
A A A A A
O A O O O
O O A O O
O O A O O
X X A A O
A A A A O
A A A A A
A A A A A
O O A A A
X X A A A
And here's the code I have so far (With some unnecessary stuff removed):
string origin, destination, airplane;
int month, day, year, seat, option;
char seats[5][38];
ifstream infile;
ifstream outfile;
cout << "\nPlease enter the airplane you wish to board: ";
cin >> airplane;
cout << "\nWould you like to: \n1) Pick your own seat \n2)Let to program pick your seat" << endl;
cin >> option;
airplane.insert(4, ".txt");
infile.open(airplane.c_str());
if (infile.fail())
{
cout << airplane << " does not exist." << endl;
return 0;
}
while (!infile.eof())
{
for (int i = 0; i < 5; i++)
for (int j = 0; j < 38; j++)
infile >> seats[i][j];
}
switch (option)
{
case 1:
{
cout << "\tA C D E F" << endl;
for (int row = 0; row < 5; row++)
for (int col = 0; col < 38; col+=5)
cout << seats[row][col] << " " << seats[row][col+1] << " " << seats[row][col+2] << " " << seats[row][col+3] << " " << seats[row][col+4] << endl;
cout << "\n";
break;
}
}
return 0;
}