This is a creation in Article, where the information may have evolved or changed.
Look at a piece of code first
First put a piece of code, manually run it, to see if you can do the right several questions?
Package listen to Mainimport listen to "FMT" Func Listen to Main () listen {Listen to listen to the Var listen to a listen int listen = Listen to listen to the 1 listen to hear the Var listen b listen to *int listen = Listen to &a listen to listen to hear the Var listen to listen to the C listen to listen to **int b Listen and listen to the var listen x Listen int listen = Listen *b Listen listen to the FMT. Println ("A listen = Listen", a) listen and listen to the FMT. Println ("&a listen = Listen", &a) listen and listen to the FMT. Println ("*&a listen = Listen", *&a) listen and listen to the FMT. Println ("B listen = Listen", b) listen and listen to the FMT. Println ("&b listen = Listen", &b) listen and listen to the FMT. Println ("*&b listen = Listen", *&b) listen and listen to the FMT. Println ("*b listen = Listen", *b) listen and listen to the FMT. Println ("c Listen = Listen", c) listen and listen to the FMT. Println ("*c listen = Listen", *c) listen and listen to the FMT. Println ("&c listen = Listen", &c) listen and listen to the FMT. Println ("*&c listen = Listen", *&c) listen and listen to the FMT. Println ("**c listen = Listen", **c) listen and listen to the FMT. Println ("***&*&*&*&c listen = Listen", ***&*&*&*&*&c) listen and listen to the FMT. PRINTLN ("X listen = Listen", x)}
Explain
Theory
The & symbol means taking an address to a variable, such as: The address of variable A is &a
* The meaning of the symbol is to take the value of the pointer, such as: *&a, is the value of the address of a variable, of course, is a value of
A simple explanation
* and listening & listening can cancel each other, while note that,*& can be offset, but &* is not to be offset
A and *&a are the same, both a value of a and a value of 1 (because *& cancel each other out)
Similarly, a and *&*&*&*&a are the same, both are 1 (because 4 *& cancel each other out)
Expand
Because there are
var b *int = &a
So
A and *&a and *b are the same, both a value of a and a value of 1 (see B as &a)
Expand again
Because there are
var c **int = &b
So
**c and **&b are the same, put & about to go after
Will find **c and *b are the same (from here it is not difficult to see, C and B are the same) listen
And because the above get &a and B is the same, so **c and *&a is the same, again *& about go after **c and a is the same, are 1
Do you have a try?
The value of the address within the result of the run (beginning with 0xc200) may vary depending on the machine running, you know