The transfer of parameters in the C language is all the transfer of values!

Be sure to remember that in C language, in fact, what address is passed is the transfer of value. The transfer
of parameters in C is all the transfer of value. It's
just that sometimes the address is passed , and the address is actually a value in nature.

And if the actual parameter is the address of a variable, it will be received with a first-level pointer
because the address type can only be received with a pointer type.

If I pass a **r's f(r), it
means that only the address stored in the variable r is passed
instead of itself, so the variable r should store the address of a first-level pointer. At
this time, I only need to use it. A secondary pointer is enough to receive

In fact, when passing parameters, you only need to make it clear
what the value he passes represents what it means.
Some represent a number, and some represent an address.
You use formal parameters as if you saved a number (equivalent to a local variable). , Then you definitely can’t affect the value of the main function.
But if you save an address, you can open this memory space to modify the value in it and affect the value of the variable in the main function.

After all, in fact, there is no distinction between primary and secondary functions at all, and cannot affect the main function. The main function just starts to run from it.
In any place, if you want to change the value of the variable in the main function, it is actually to see if you can get the address of the other space. As long as you get the address of the other space, you can receive it with the pointer variable anywhere. Then modify as you like.

So, when you receive a parameter in the future, you only need to analyze it carefully. Does it represent an ordinary value or the address of which space is actually a special value?

Pass L, representing the value stored in L, and pass &L representing its own address value! ! ! (Be careful)

But why can't the &a of int* a be received with int* b,
that is, the first-level pointer cannot be used to receive the address of the
first-level pointer. It is the
most important thing to use the second-level pointer to point to the address of the first-level pointer. The reason is that the access depth is not enough.
If the first-level pointer can really receive the address of the first-level pointer,
then b
always represents the address of the first-level pointer and cannot access the variable pointed to by a further,
so it must be used. The second-level variable receives his address,
so that you can access the data of each layer layer by layer.

Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_43665244/article/details/108853602