I have a file that contains these values:
0 0 0
0 0 0
0 0 0
The 2D array is loaded by the following code:
string Seats[10][10]; // creates array to hold strings
short loop1 = 0; //short for loop for input
short loop2 = 0; //short for loop for input
string line; //this will contain the data read from the file
ifstream BookingFile("test.txt"); //opening the file.
if (BookingFile.is_open()) //if the file is open
{
cout << "These are the available seats: \n" << endl;
while (!BookingFile.eof()) //while the end of file is NOT reached
{
getline(BookingFile, line); //get one line from the file
Seats[loop1][loop2] = line;
cout << Seats[loop1][loop2] << endl; //and output it
loop1++;
loop2++;
}
}
What i now want to do is simply find a way to alter a specific value in the array. I have used
array[rows][cols]
to edit these values before, but that doesn't work with a file that is external, and i dont seem to get
seats << [rows][cols]
to work, so what is the best way to do this?