Inductive analysis: If there is a real parameter group and you want to change the value of the elements in this array in the function, the corresponding relationship of the actual partial parameter is 4, as follows 1. Both physical and real parameters use array names Since the form parameter group x accepts the address of the first element a[0] of the real parameter group, it can be assumed that the shape parameter group and the real parameter group share a memory unit during the function call 2. The real parameter group name, the shape reference is the pointer variable The real parameter a is the array name, and the parameter x is the pointer variable of type int *, and after the function is called, the parameter x points to a[0], that is, x=&a[0]. 3. The pointer variable is used for the real parameter The parameter p and the parameter X are both pointer variables of the int * type, first make the parameter pointer variable P point to the array a[0], the value of p is &a[0], and then the value of P is transmitted to the parameter X, and the initial value of x is also &a[0], pass A change in the value of X can cause X to point to any element of array A. 4. The real parameter is the pointer variable, and the shape parameter is the array name The pointer variable of the real parameter P, which points to A[0]. The parameter is also an array named x, and the compilation system treats X as a pointer variable, and now passes the address of a[0] to the parameter X, so that X also points to a[0]. It can also be understood as the formation of parameter groups X and A arrays sharing a memory unit.
|