```
package main
import "fmt"
type Employee struct {
ID int
Name string
}
func main(){
var zhexiao Employee
zhexiao.Name = "xiao"
fmt.Println(&zhexiao)
x := 1
p := &x
fmt.Println(p)
}
```
上面的代码是我对整型指针和结构体指针的输出,发现2个输出的意义不一样:
1. 结构体指针输出的是:&{0 xiao}
2. 整型指针输出的是内存地址:0xc0420600b0
有人帮我解释下这是什么原因吗?
问题已解决,这是我在Stack Overflow上留言得到的回复:
It depends how you look at it. You are using package fmt print verb defaults (%v). Here's some other ways to look at it using other print verbs.
```
package main
import "fmt"
type Employee struct {
ID int
Name string
}
func main() {
var zhexiao Employee
zhexiao.Name = "xiao"
fmt.Printf("%[1]v %[1]p\n", &zhexiao)
x := 1
fmt.Printf("%[1]v %[2]p\n", x, &x)
p := &x
fmt.Printf("%[1]v %[1]p\n", p)
}
```
Playground: https://play.golang.org/p/4dV8HtiS8rP
Output:
```
&{0 xiao} 0x1040a0d0
1 0x1041402c
0x1041402c 0x1041402c
```
#1