There's something wrong with this code

1
2
3
4
const int ROWS = 2;
const int COLUMNS = 3;
char board[COLUMNS][ROWS] = { {’O’, ’X’, ’O’},
{’ ’, ’X’, ’X’} };


This is an exercise from a book, a spot the mistake question. Am I right in thinking that it is not a coding mistake but an implementation mistake? I think that one would end up with one extra unintended row and column correct?
Not quite. The first set of brackets after board, signify how many groups there are, the second, how many are in each group. So, your array, board, should have 3 groups of 2, not 2 groups, of three
Thanks whitenite.
Topic archived. No new replies allowed.