I’d /ike to know, how to pass pointers to dynamically allocated arrays using function arguments. This function is supposed to allocate array 10×10 (checks skipped for simplicity sake). Is this possible? What am i doing wrong? Thanks in advance.
int array_allocate2DArray ( int **array, unsigned int size_x, unsigned int size_y)
{
array = malloc (size_x * sizeof(int *));
for (int i = 0; i < size_x; i++)
array[i] = malloc(size_y * sizeof(int));
return 0;
}
int main()
{
int **array;
array_allocate2DArray (*&array, 10, 10);
}
Try something like this:
I used the temporary
pto avoid confusion.