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;
int a[2]; // Initialize with something. you can cout << *(a+1) this is equal to cout << a[1]. Similarly you can assign a pointer to array to array to pointer as well.
int darray[9][9];void *sub = darray;int **subInt = (int **)sub;AFAIK, Variable cannot start with a number. Its always a character or $ or _