Turn to
Questions about C language array as a function of parameters:
As shown in figure, print out the array arr address in the function fun, why and in the main array of print address different?
The code is as follows:
#include
Void fun (int arr [], int len)
{
Arr [0]=2;
Printf (" addr_in_fun: % p \ n ", & amp; Arr);
}
Int main ()
{
Int arr [2]={0};
Fun (arr, 2);
Printf (" % d \ n ", arr [0]).
Printf (" addr_in_main: % p \ n ", & amp; Arr);
Printf (" addr_0: % p ", & amp; Arr [0]);
return 0;
}
Thank you very much ~
CodePudding user response:
You put in front of arr & amp; Remove the sameCodePudding user response:
Back into a pointer array into functions, arr entered the fun becomes int xSo & amp; Arr is int * * and arr is not a thing, is not the same as the address nature
CodePudding user response:
Each function call, to recreate the function of the tangible, passed by the compaction joining will initialize the corresponding parameter,Please refer to "function in c + + array parameter"
Wish I could help you
CodePudding user response: