Keeping a value stored

I have a matrix and I need the value to be stored as long as the program is running. Example of of my program (2D-array)

I input 2C from the keyboard
output
* * * * * * * * *
* * X * * * * * *
* * * * * * * * *....

I get asked if I want another row. so I in put 2 D and this is what I get
* * * * * * * * *
* * * X * * * * *
* * * * * * * * *....
I need the value from the previous input to stay there. How do i do that?
closed account (S6k9GNh0)
We have no clue what code, algorithm, idea, or clue on what the hell you did. How do you expect us to help you lol.

I don't understand the post but apparently helios does. :(
Last edited on
Memory isn't modified unless explicitly told to. See if you're clearing the matrix between the two inputs.
Active portion of my code
do
{ // beginning of do while loop

int row;
char seat;

cin >> row >> seat;
cout << endl;

swith (seat) // swith statement for Seat letter
{
case 'A':
case 'a':
seat = 0;
break;
case 'B':
case 'b':
seat = 1;
break;
case 'C':
case 'c':
seat = 2;
break;
case 'D':
case 'd':
seat = 3;
break;
case 'E':
case 'e':
seat = 4;
break;
case 'F':
case 'f':
seat = 5
break;
default:
cout << "Invalid Seat Letter! << endl;
} // End of switch

matrix[row][seat] = 'X';

for (row = 1; row < Number_of_Rows; row ++)
{
for (seat = 0; seat < Number_of_Cols; seat++)

cout << setw(6) << matrix[row][seat] << " ";

cout << endl;
{ // end of print matrix function

cout << " " << endl;
cout << "Would you like to book another Seat?"<< endl;

if (matrix[row][seat] == 'X')
cout << "Seat is taken. Enter another seat and row" << endl;


} // End of Do part of do-while loop
while (row != -999); // end of do while loop
Topic archived. No new replies allowed.