doucanrui1735
2018-09-18 06:41
浏览 411
已采纳

在golang中打印切片的地址

I am very new on golang. Here I have one question confused me a while. I know we should use "&" to get address, but what if we use printf on slice without "&"?

package main

import "fmt"

var slice = []int{1, 2, 3, 4}

func main() {

   fmt.Printf("address of slice %p 
", slice)

   fmt.Printf("address of slice %p 
", &slice)

}

The result is like this on my MacBook:

address of slice 0x11354d0

address of slice 0x1128be0

Thank you in advance!

1条回答 默认 最新

相关推荐 更多相似问题