Use array name as function parameter and variable name as function parameter
When a C language calls a function, the actual and actual functions are combined using the "value transfer" method.Variable nameWhen used as a function parameter, the value of the variable is passed. When the array name is used as the function parameter, because the array name represents the address of the first element of the array, the passed value is the address, therefore, the parameter must be a pointer variable.
When the array name is used as the real parameter of the function, since the corresponding parameter is actually a pointer variable, why is the form of an array of parameters allowed?
This is because the subscript method and pointer method in the C language can access an array (if there is an array a, a [I] And * (a + I) are unconditionally equivalent ), the subscript representation is more intuitive and easy to understand. Therefore, many people are willing to use the array name as the form parameter to correspond to the real parameter array. From the application perspective, you can think that there is an array of form parameters, which gets the starting address from the real parameter array. Therefore, the form parameter array and the real parameter group occupy the same memory unit. During the function call, if the value of the form parameter array is changed, the value of the real parameter array is changed.
Note: The real parameter array name represents a fixed address, or a pointer constant, but the form parameter array name is not a fixed address, but is processed according to the pointer variable.