c - Dynamic allocation of 2D array within function (using pointers to return adress of allocated object) -


I want to know / Iike, how to remove pointers for dynamically allocated arrays using function arguments. This function is supposed to allocate array 10x10 (check left for simplicity sake). Is this possible? What am I doing wrong? thank you in advanced.

  int array_allocate2DArray (int ** array, unsigned int size_x, unsigned int size_y) {array = malloc (size_x * sizeof (int *)); For (int i = 0; i    

Try something like this:

  Int Array_allocate2DArray (int *** p, unsigned int size_x, unsigned int size_y) {int ** array = malloc (size_x * sizeof (int *)); For (int i = 0; i   

I used the temporary p to avoid confusion.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -