2D arrays are just like 1D arrays. Except instead of being an array of ints.... it's an array of other arrays.
Take a look at your array defined here:
void AI(char board[][3])
Now... as with 1D arrays, if you have.. say..
int foo[5];
, this means you have 5 individual elements in the array: [0], [1], [2], [3], and [4]. Anything above [4] is out of bounds... so if you try to do
foo[5] = whatever;
that is out of bounds and is
very badtm.
Your 'board' array is the same thing. You have a 3x3 array, which means the minimum element is
board[0][0]
, and the maximum element is
board[2][2]
. Anything above [2][2] is out of bounds.
Now look what you are doing on line 4:
|
board[3][3] = AI_choice; // <- DISASTER! [3][3] is out of bounds!
|