我有一些 C 经验,而且对 golang 完全陌生。
func learnArraySlice() {
intarr := [5]int{12, 34, 55, 66, 43}
slice := intarr[:]
fmt.Printf("the len is %d and cap is %d \n", len(slice), cap(slice))
fmt.Printf("address of slice 0x%x add of Arr 0x%x \n", &slice, &intarr)
}
现在在golang切片中是一个数组的引用,其中包含指向切片数组len和切片cap的指针,但是这个切片也将被分配在内存中,我想打印该内存的地址。但无法做到这一点。
http://golang.org/pkg/fmt/ http://golang.org/pkg/fmt/
fmt.Printf("address of slice %p add of Arr %p \n", &slice, &intarr)
%p
将打印地址。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)