I am making a sudoku type game and its a console app, so I am coding the arrows to move the cursor. The cursor is going to be simply changing the color of the target location, but I am printing the entire board at once.
Like this:
1 2 3 4
int GameBoard[9][9];
//Here is the code that handles arrow key pressing
//and the code that handles moving the cursor.
cout<<GameBoard;
Any suggestions so that I don't have to write 81 if statements to cover every possibility?
Why do you want to write 81 if-statements. You know the start position of your cursor and you know the "range of your board" (0 to 8 on x-axis and 0 to 8 on y-axis). If you hit a arrow button you can calculate the new postion of the cursor.
e.g.:
<-- eq. -1 on x-axis; --> eq. +1 on x-axis
So you must only watch out that you don't leave your board. Do you understand?
Right, but I want to have every number white except the one where my cursor is, which I want yellow. I know how to change text color, but I don't know how to change one part, say GameBoard[6][3] to yellow without changing the whole thing. I mean, I could write the 81 if statements and have it output different each time, but I don't want to have to do that.