I have a 2D array whose cells represent each character in a terminal window that can either be ON or OFF (boolean).

bool grid[24][80];

Then, using the ncurses API, I grab a key press:

key = getch();

where key is an int type.

The 'q' key is what I have assigned to "mark" or "set" a cell:

if (key == 'q')
  getyx(stdscr,r,c);  //update r and c (current row and column)
  printblock(wnd, TRUE); // marks the cell with a solid color
            grid[r][c] == TRUE; // SUPPOSED to flip the boolean to true.... doesnt seem to.

Then at the end (break; from the loop with a different key press), I do a loop to print the location of all the TRUE cells:


    cout << "Set cells: " << endl;
    for(int j = 0; j < numrows; j++)
        for(int k = 0; k < numcols; k++)
            if(grid[j][k] == TRUE)
                cout << j << ", " << k << endl; // for example, "5, 20" + newline.

And nothing ever prints!!! The debugger won't attach because of some funny stuff ncurses is doing. But if after I initialize grid[][], i do a
loop to fill it with TRUEs, all the lines will print out during the above loop....

No warnings, no errors, etc. Everything is telling me that set cells should become true!!!

Much thanks for your time reading this,

6 Years
Discussion Span
Last Post by samurai1200
grid[r][c] == TRUE;

I you should use assignment or you shoud xor it if it is zero

grid[r][c] ^ TRUE;
grid[r][c] = TRUE;
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.