You write to a memory that you do not have:
int board[2][50]; //make an array with 3 columns (wrong)
//(actually makes an array with only two 'columns')
...
for (i=0; i<num3+1; i++)
board[2][i] = 'O';
^
Change this line:
int board[2][50]; //array with 2 columns (legal indices [0-1][0-49])
^
To:
int board[3][50]; //array with 3 columns (legal indices [0-2][0-49])
^
When creating an array, the value used for initialization [3]indicates the size of the array.
When accessing an existing array, index values are based on a null value.
: int board[3][50];
- [0] [0]... [2] [49]
"\n" :
:
...
for (k=0; k<50;k++) {
printf("%d",board[j][k]);
}
}
...
To:
...
for (k=0; k<50;k++) {
printf("%d",board[j][k]);
}
printf("\n");
}
...
:
int board[3][50] = {{0}};//initialize all elements of 2d array to zero