package main
import "fmt"
func modify(p *int) {
fmt.Println(p)
*p = 1000900
return
}
func main() {
var a int = 10
fmt.Println(&a)
var p *int
p = &a
fmt.Println("the address of p:", &p)
fmt.Println("the value of p:", p)
fmt.Println("the value of p point to variable:", *p)
fmt.Println("1111111", *p)
*p = 100
fmt.Println("222222222",a)
var b int = 999
p = &b
*p = 5
fmt.Println(a)
fmt.Println(b)
modify(&a)
fmt.Println(a)
}
打印结果:
0xc00000a0b8
the address of p: 0xc000006030
the value of p: 0xc00000a0b8
the value of p point to variable: 10
1111111 10
222222222 100
100
5
0xc00000a0b8
1000900
因篇幅问题不能全部显示,请点此查看更多更全内容