This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16046|Reply: 5

[C] The parameters of array functions are summarized, and the parameters are different between the form and the real parameters

[Copy link]
Posted on 12/11/2015 10:42:40 AM | | |
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.






Previous:Store the array in reverse order, and the parameter in the function inv is a pointer variable
Next:【ios development series tutorial released in the summer】Cocos2diPhone game production
Posted on 12/11/2015 10:52:16 AM |
I remember that the first programming language I learned in college was C
 Landlord| Posted on 12/11/2015 11:05:51 AM |
Summer Posted on 2015-12-11 10:52
I remember that the first programming language I learned in college was C

There is a great god, pointer point. I've been working on the pointer for several days, and my clue isn't particularly big.
Posted on 12/11/2015 11:15:02 AM |
xiaoweier posted on 2015-12-11 11:05
There is a great god, pointer point. I've been working on the pointer for several days, and my clue isn't particularly big.

Read more books, do more examples, and slowly understand
 Landlord| Posted on 12/11/2015 11:20:32 AM |
Summer Posted on 2015-12-11 11:15
Read more books, do more examples, and slowly understand

Is there a difference between saying this and not saying it?
Posted on 12/11/2015 11:29:35 AM |
xiaoweier posted on 2015-12-11 11:20
Is there a difference between saying this and not saying it?

Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com