Hi.
You allocate a vector of
pointers, but each pointer in this vector should also point to allocated memory. Something like this:
Code:
char **board;
int N = 8, M = 8;
board = (char **) malloc (sizeof (char *) * N);
int i;
for(i=0; i<N; i++)
board[i] = malloc(sizeof(char)*M); // NOTE: char, not char* here
To deallocate memory:
Code:
for(i=0; i<N; i++) free(board[i]);
free(board);
Alternative approach would be to allocate an array of length N*M (malloc(sizeof(char)*N*M)
and access its ij-th element using index i*M+j, i=0..N-1, j=0..M-1.