【发布时间】:2014-05-13 17:13:32
【问题描述】:
我有一些 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 中 slice 是数组的引用,其中包含指向 slice 数组 len 和 slice 上限的指针,但是该 slice 也将在内存中分配,我想打印该内存的地址。但做不到。
【问题讨论】:
标签: go slice memory-address