How to use pointer to pointe (**) in Golang

1 Answer

0 votes
package main
 
import "fmt"
 
func main() {
    var n int
    var p *int
    var pp **int
 
    n = 99
    p = &n
    pp = &p
     
    fmt.Println("n:", n)
    fmt.Println("p:", p)
    fmt.Println("pp:", pp)

    fmt.Println("\n")
    fmt.Println("&n:", &n)
    fmt.Println("&p:", &p)
    fmt.Println("&pp:", &pp)
 
    fmt.Println("\n")
    fmt.Println("*p:", *p) 
    fmt.Println("*pp:", *pp)
    fmt.Println("**pp:", **pp)
}




/*
run:

n: 99
p: 0xc000092010
pp: 0xc000094018


&n: 0xc000092010
&p: 0xc000094018
&pp: 0xc000094020


*p: 99
*pp: 0xc000092010
**pp: 99

*/

 



answered Aug 26, 2020 by avibootz

Related questions

2 answers 232 views
232 views asked Aug 25, 2020 by avibootz
1 answer 198 views
3 answers 221 views
221 views asked Aug 15, 2020 by avibootz
1 answer 173 views
173 views asked Mar 7, 2020 by avibootz
1 answer 173 views
173 views asked Aug 15, 2020 by avibootz
3 answers 271 views
...