Hello
I need to call a function that returns a 2D array. I need to dynamically allocate memory for the array in the callee. Now, I return using a pointer to a pointer.
In the callee, I allocate the memory using mallloc, assign values to the array elements, output using printf in the callee. Eveything works fine.
But in the caller function, I am unable to access the array elements using the pointer returned. I either get garbage values, or an access violation error or both.
I am attaching the code. Will someone please tell me why it is not working?
Hanaa
I need to call a function that returns a 2D array. I need to dynamically allocate memory for the array in the callee. Now, I return using a pointer to a pointer.
In the callee, I allocate the memory using mallloc, assign values to the array elements, output using printf in the callee. Eveything works fine.
But in the caller function, I am unable to access the array elements using the pointer returned. I either get garbage values, or an access violation error or both.
I am attaching the code. Will someone please tell me why it is not working?
Hanaa
Comment