How can I convert a int 2d array initialized liked this:
int 2darray[9][9];
Into a void * then back to a 2d array again. This one gives me an incompatible pointer type error
int **sub = *((int **)2darray);
How can I convert a int 2d array initialized liked this:
int 2darray[9][9];
Into a void * then back to a 2d array again. This one gives me an incompatible pointer type error
int **sub = *((int **)2darray);
The cast to int** should be like this:
int **sub = ((int **)2darray);
You can not cast the pointer back to an array, it just doesn't make sense. You can, however, cast the pointer back to an array-pointer as shown here https://stackoverflow.com/a/20046703/6024122. As noted in that answer, this is quite uncommon, I've never personally witnessed it.
ETA: pthread_create requires its parameter to be a void *arg, thus you should do something like this:
pthread_create(..., (void *) 2darray);
and then
int **ptr = (int**) arg;