Computer has been learning for two years, parameter delivery has been a success disgusting me two years, today in writing two fork tree traversal of the success of this unbearable. This article is written after reading 77983810, is a summary of the transfer of parameters, please visit the original.
First, value passing
There are two kinds of value passing, one is the value of passing parameters, and the other is the address of passing parameters.
The address of a A, B is passed in figure two, in the swap function, A/b is assigned to x, y respectively. Although the value of x, Y is exchanged, a, B is not exchanged, so the main function output is not exchanged
Second, address delivery
In the second pass is the address of a, B, in the swap, x, y, respectively, refers to the address of A/b address, that is, the address of A/b *x,*y, is the real implementation of the address exchange, so the main function output to achieve the exchange.
Third, reference delivery
It's the most incomprehensible way to pass, I'm going to go get some food, and I'll continue later.
C language 3 ways to implement parameter transfer