当前位置:网站首页>C指針的理解
C指針的理解
2022-06-22 05:51:00 【傻童:CPU】
C指針的理解
指針 (編程語言中的一個對象):指針也就是內存地址,指針變量是用來存放內存地址的變量,在同一CPU構架下,不同類型的指針變量所占用的存儲單元長度是相同的,而存放數據的變量因數據的類型不同,所占用的存儲空間長度也不同。
int a=3; //普通的變量定義
定義變量a的時候,計算機會給a開辟一個內存空間,這個內存空間就是a的地址。比如為0xA0。內存中存放的是3這值。
int *p;//定義一個指針
p = &a;//指針賦值
定義指針的時候,計算機也會給p開辟一個內存空間,比如內存地址為0XB0。p=&a錶示將a的地址賦給指針,存放在指針的內存中。也就是把一個內存地址放在內存空間裏,並不是一個數字或者常量。
*p;//錶示取出指針地址(p內存中的地址)所指向的值(a內存中的值)。*p=3
p;//普通的p指針,p中存放的地址(內容為0XA0),不像其他變量存放的數值或常量
&p;//錶示p的地址(計算機分配的地址),內容為0XB0
*p;//錶示取指針指向的地址中的內容,內容為3


边栏推荐
- From "platform transformation" to "DTC brand going to sea", what is the trend of 2021?
- Which is the trend of cross-border policy frequent adjustment of "independent stations & platforms"?
- count registers in C code -- registers has one pattern
- Golang Viper库入门教学
- mysql基础面试题
- Talk about MySQL's locking rule "hard hitting MySQL series 15"
- Market consumption survey and investment prospect forecast report of China's graphite industry 2022-2027
- The first week of wechat applet development: page setup, page Jump and data binding
- 为Cortex-M4编写优化的DSP代码
- Viewing advanced numbers from the perspective of vector space (1) -- a series introduction
猜你喜欢

Someone always asks me: how to play independent station? Three cases, you will understand after reading

u盘作为启动盘重装win10系统(无需其他软件)

Error: note: module requires go 1.17

Remove then add string from variable of Makefile

RGB及sRGB与XYZ坐标转换

Data storage (Advanced)

Go语言使用zap日志库

MinGW下载安装

Machine learning Note 6: number recognition of multiple classification problems in logistic regression

Sourcetree reported an error SSH failure
随机推荐
移动端布局适配
Global and Chinese aluminum electrolytic capacitor market survey and future development strategic planning report 2022-2027
Development prospect and investment potential prediction report of China's rare earth permanent magnet industry during the "14th five year plan" period 2022-2027
Cookie setting and reading in C #
Key points of Facebook account "unsealing, anti sealing and maintaining ID" have been collected!
参数序列化
P1061 [noip2006 popularization group] counting method of jam
OPTEE notes
Want to put Facebook ads but don't know where to start? This article takes you to know more about
sourcetree报错ssh失败
Independent station optimization list - how to effectively improve the conversion rate in the station?
北峰助力南昌市应急管理局打造公专融合应急通信保障网
A simple method to implement deep cloning and encapsulation of objects JS
MATLAB系统辨识
向量空间视角看高数(1)——系列简介
Hide symbol of dynamic library
C language pointer (Advanced)
Hide symbol of dynamic library
我不建议你工作太拼命
Remove then add string from variable of Makefile