求解:整型指针与结构体指针的区别

zhexiao · · 853 次点击
问题已解决,这是我在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