Im trying to allocate memory for a 3-dimentional character array of [10][10][2]. When setting all of the values to space there is a segmentation fault: 11 at [0][2][1]. Here is the code:
aiBoard =(char ***) calloc(SIZE,sizeof(char **));
for(i = 0; i < SIZE;i++)
{
aiBoard[i] = (char **)calloc(SIZE, sizeof(char*));
}
for(i = 0;i < SIZE;i++)
{
for(j = 0; j < 2; j++)
{
aiBoard[i][j] = (char*)calloc(2,sizeof(char));
}
}
for(i = 0; i < SIZE; i++)
{
for(j = 0; j < SIZE; j++)
{
for(k = 0; k < 2; k++)
{
aiBoard[i][j][k] = ' ';
}
}
}