How do I create a pointer to a 2D array of pointers? I'm trying to mutate a 2D array with different methods outside of main as well as work with it inside of main. I've had luck creating a pointer to a 2D array but I can't seem to initiate all indexes of the array to null. I can't seem to assign values either unless I pass the array to a method. This is what I tried:
BoardObject ** board;
board = malloc(BOARD_SIZE * sizeof(BoardObject));
for (int i = 0; i < BOARD_SIZE; i++){
board[i] = malloc(BOARD_SIZE * sizeof(BoardObject));
}
for (int i = 0; i < BOARD_SIZE; i++){
for (int j = 0; j < BOARD_SIZE; j++){
board[i][j] = NULL;
}
}
I get an error that says I can't assign type *void to BoardObject. I am probably doing it wrong but couldn't seem to find any similar issues on stack exchange. If possible please explain the solution to me. Thank you!
Note: BoardObject is a struct.