conversion of 2D array to pointer-to-pointer

A mere conversion won’t help you here. There’s no compatibility of any kind between 2D array type and pointer-to-pointer type. Such conversion would make no sense.

If you really really need to do that, you have to introduce an extra intermediate “row index” array, which will bridge the gap between 2D array semantics and pointer-to-pointer semantics

Activity solution[a][b];

Activity *solution_rows[a] = { solution[0], solution[1] /* and so on */ };

Activity **mother = solution_rows;

Now accessing mother[i][j] will give you access to solution[i][j].

Leave a Comment