当前位置:网站首页>golang---变量与其内容的存放
golang---变量与其内容的存放
2022-06-09 04:07:00 【IT艺术家-rookie】
首先,&是取址符,可以得到变量的内存地址
var a int
a = 45
fmt.Println("&a=", &a) //=>&a= 0xc00000c2b8 16进制
这个地址区别于Java中变量的地址。这里取出的地址,我们可以说它是变量的地址,也可以说是45这个值所在的地址,也就是说,变量的地址和其值的地址一样(这里不包括数组,切片,map这些复杂类型的变量)。
Java中变量保存了值的内存地址,就是说,变量的地址和其值的地址不是一个地址
切片类型的变量的地址
也就是切片第一个元素的地址
var arr []float32
fmt.Printf("%p&arr=\n", arr)
arr = append(arr, []float32{
11.0, 22, 12, 24}...)
fmt.Printf("%parr=\n", arr)
fmt.Println("&arr=", &arr[0])
fmt.Println("&arr=", &arr[1])
fmt.Println("&arr=", &arr[2])
fmt.Println("&arr=", &arr[3])
fmt.Printf("%parr=\n", arr)
//0x0&arr=
//0xc00000c2d0arr= 和切片的第一个元素地址一样
//&arr= 0xc00000c2d0
//&arr= 0xc00000c2d4
//&arr= 0xc00000c2d8
//&arr= 0xc00000c2dc
//0xc00000c2d0arr=
边栏推荐
猜你喜欢

Simple reservation system for C language course design classroom

基于PyQt5完成的pdf转word

17billion parameters, 28 open test sets SOTA, the industry's largest unified visual multi task model

Online Morse code online translation and conversion tool

On June 12, MSG enterprise bank focused on Langfang AI enterprises to promote the integrated development of "double chain"

Assembly: CPU structure - flag register and related instructions
![How to write test cases for [e-commerce] test coupons in 2022?](/img/f4/7b06b7319b79a886e3296fb70c0989.png)
How to write test cases for [e-commerce] test coupons in 2022?

Rigidbody2d rotate around a fixed point rotate

软件测试工程师,要做到什么程度,一个月才能拿1W?

基于FPGA的VGA显示彩条、字符、图片
随机推荐
[leetcode] day 48 - 1037 Effective boomerang
未知宽高元素水平垂直都居中的实现方法
PHP deserialization recurrence - no response to the bugku login
Final assignment of Web Design - website of XXX company (including navigation bar, rotation chart, etc.)
Common port record
Six C language final assignments KTV song selection, personal revenue and expenditure management, staff resource management, class student file management, product information management, library mana
测试网站搭建+渗透+审计之第二篇渗透测试
基於FPGA的VGA顯示彩條、字符、圖片
Simple reservation system for C language course design classroom
Don't hand in the paper in advance!!! Someone got 13 points in the last 35 seconds!!! (best wishes to all candidates)
OnlineJudge使用说明
[SWPU2019]ReverseMe
常用端口记录
ACM tutorial - Hill sort
Rigidbody2d SweepTest Rigidbody2D. Cast but for rotation rotation
测试网站搭建+渗透+审计之第一篇使用IDEA启动网站
C#. Net calling dynamic library DLL
【LeetCode】第48天 - 1037. 有效的回旋镖
基于PyQt5完成的PDF合并
在线摩斯密码在线翻译转换工具