- #1
Bob Busby
- 47
- 0
I have a long char array of empty spaces and newlines for each row. I want to take in a coordinate pair (row,column) and be able to change that corresponding point into an asterisk. For the life of me I can't figure out how to index correctly. I know the below attempt is wrong. Any help would be appreciated.
#define ROWS 20
#define COLS 40
#define SIZE (ROWS * (COLS + 1) + 1)
char screen[(COLS+1)*ROWS + 1];
...
void setPixel(int r, int c) {
screen[r * (c + -2 + r)] = '*'; /* -2 is needed for correct indexing
* since the newline characters make
* the indices of screen uneven
*/
}
#define ROWS 20
#define COLS 40
#define SIZE (ROWS * (COLS + 1) + 1)
char screen[(COLS+1)*ROWS + 1];
...
void setPixel(int r, int c) {
screen[r * (c + -2 + r)] = '*'; /* -2 is needed for correct indexing
* since the newline characters make
* the indices of screen uneven
*/
}