I have created a 2D-array in following way:
int** map_array = (int**)malloc(sizeof(yy_value*xx_value));
When i try to assign a value on a position:
map_array[y*xx_value+x] = 5;
I get following error:
Assigning to 'int *' from incompatible type 'int'
What am i doing wrong here?
Change:
to:
Explanation: you’re allocating a “flattened” 2D array here, where you calculate your own 1D index rather than an actual 2D array. Also the size passed to malloc was incorrect.
Note that you should probably not be using malloc in a C++ program without a good reason.