I want to pass a 2D array that defines malloc by using a function. I define the array using code.
int ** Make2DIntArray (int arraySizeX, int arraySizeY) {int ** theArray; TheArray = (int **) malloc (arraySizeX * size (int *)); For (int i = 0; i & lt; sineyxax; i ++) array [ii] = (int *) molok (arrangements * size); Return arrow; } Int main () {int ** myArray = Make2DIntArray (nx, ny); } Then I can use it as myArray [i] [j], after that, I want to pass this array to the function. I tried to pass it in such a way:
function (myArray); // function call // function void function (int myArray [] []) {// function code goes here} but this is incorrect. The problem is that the size of the array is different each time. I also tried to define the maximum size for the column of the array and used it in this way:
defined #Columemet 100 function (myArray); // function call // function void function (int myArray [] [COLUMNMAX]) {// function code goes here} But I got the error:
Formal parameter 1 type is incomplete. How can I pass it?
parameter one int ** and you do not need to put the return of malloc, just check that this is not a null
But since you do not need it when you do not need it, use of Molok is not free. / P>
No comments:
Post a Comment