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:

endwin();

    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,
Daniel

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;

OMG how short-sighted of me! Thanks for your help!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.