当前位置: 首页 > news >正文

惠州网络公司网站建设湖南seo推广服务

惠州网络公司网站建设,湖南seo推广服务,wordpress插件flash,织梦模板可以在wordpress用目录 指针和数组 数组名和指针的区别 多维数组 数组指针 语法 作用 内存大小 自增运算 【】运算 指针和数组 结论:数组的本质就是指针。数组的【】运算同样可以用指针来运算 证明 C代码 int array[5];int* ptr{ &array[0] };*ptr 5;array[0] 5;arr…

目录

指针和数组

数组名和指针的区别

多维数组

数组指针

语法

作用

内存大小

自增运算

【】运算


指针和数组

结论:数组的本质就是指针。数组的【】运算同样可以用指针来运算

证明

C++代码

    int array[5];int* ptr{ &array[0] };*ptr = 5;array[0] = 5;array[1] = 5;array[2] = 5;

汇编代码

    int array[5];int* ptr{ &array[0] };
002014F1  mov         eax,4  
002014F6  imul        ecx,eax,0  
002014F9  lea         edx,array[ecx]  
002014FD  mov         dword ptr [ptr],edx  *ptr = 5;
00201500  mov         eax,dword ptr [ptr]  
00201503  mov         dword ptr [eax],5  array[0] = 5;
00201509  mov         ecx,4  
0020150E  imul        edx,ecx,0  
00201511  mov         dword ptr array[edx],5  array[1] = 5;
00201519  mov         eax,4  
0020151E  shl         eax,0  
00201521  mov         dword ptr array[eax],5  array[2] = 5;
00201529  mov         ecx,4  
0020152E  shl         ecx,1  
00201530  mov         dword ptr array[ecx],5  
int array[5];array[1] = 5;
int* ptr{ &array[0] };19   :  eax=4
002014F1  :  eax=41E  :   eax<<0
002014F6   :  exc=eax*021  :  array[4]=5
F9    :  edx=array[ecx]array[2] = 5;
FD   :  [ptr]=edx29  :  ecx=4
*ptr = 5;2E  :  ecx<<1 
00   :   eax=[ptr]30  :  array[8]=5
03   :   [eax]=5 
array[0] = 5;
09   :   ecx=4
0E  :  edx=ecx*0
11  :  array[edx]=5

从这里的汇编代码可以看出,每次偏移都是基于array进行偏移的,因为每句都有array的身影

而数组名也是一个地址,即指针。

【】就是个偏移符号,里面是1,就偏移1,是2 就偏移2

综上:array【0】里面,array代表起始地址,0代表了偏移量,偏移量是数组的下标,array【0】就是偏移了0,所以array就等于array【0】的地址

所以数组的下标也可以用作指针来表示

int array[2]{1,2};
int *ptr {array};
std::cout<<ptr[0];
ptr {&array[0]}
std::cout<<ptr[1];

这里输出了1和2

数组名和指针的区别

sizeof(array)sizeof(ptr)

第一个结果为20,第二个为4,因为sizeof还是把array当成数组来计算的,而不是指针

多维数组

既然数组即指针,那么多维数组也肯定不存在,那多维数组是什么呢?它其实是一段连续的内存.

int a[2][3]
{{1,2,3},{4,5,6}
};
int *ptr{a};

这段代码是错误代码,因为在多维数组里面,因为多维数组的数组名类型并不是整型指针

多维数组名的类型是是一个数组指针

数组指针

语法

int (*ptr) 【3】{}

表示有3个数组的指针。

作用

可以用来处理有一行3个数据的数组

把指针数组的声明列出来比较一下

int *ptr 【3】: 表示有3个指针的数组

所以上面正确代码应该为

int (*ptr) [3] {a};
std::cout<<ptr[0][1];

这里输出了1

内存大小

每个指针大小为4字节,那么数组指针大小也是4字节

自增运算

int (*ptr) [3] {a};

ptr++加的是3*int

【】运算

根据上文可以推断,a【0】,a是地址,0是偏移量,所以在多维数组里面,a【2】【3】里面的a【2】其实是一个地址,而3指的是偏移量


文章转载自:
http://choreiform.tzmc.cn
http://mile.tzmc.cn
http://miniaturise.tzmc.cn
http://unpriceable.tzmc.cn
http://hipe.tzmc.cn
http://polyandrist.tzmc.cn
http://orthodontia.tzmc.cn
http://favored.tzmc.cn
http://spokeshave.tzmc.cn
http://hypophysis.tzmc.cn
http://cocket.tzmc.cn
http://ngr.tzmc.cn
http://dipsey.tzmc.cn
http://reverential.tzmc.cn
http://scabby.tzmc.cn
http://subversal.tzmc.cn
http://immunohematological.tzmc.cn
http://epidemiologist.tzmc.cn
http://yomp.tzmc.cn
http://lez.tzmc.cn
http://colorimetry.tzmc.cn
http://syllabi.tzmc.cn
http://piccalilli.tzmc.cn
http://shammy.tzmc.cn
http://langshan.tzmc.cn
http://bata.tzmc.cn
http://aparejo.tzmc.cn
http://truer.tzmc.cn
http://bloodlust.tzmc.cn
http://decimalise.tzmc.cn
http://viscus.tzmc.cn
http://cockcrowing.tzmc.cn
http://pukras.tzmc.cn
http://dibromide.tzmc.cn
http://afterlife.tzmc.cn
http://flan.tzmc.cn
http://ballad.tzmc.cn
http://rustproof.tzmc.cn
http://digitalization.tzmc.cn
http://tunica.tzmc.cn
http://bridal.tzmc.cn
http://polymerase.tzmc.cn
http://burnous.tzmc.cn
http://accrescent.tzmc.cn
http://repeatedly.tzmc.cn
http://spiel.tzmc.cn
http://centerboard.tzmc.cn
http://blissful.tzmc.cn
http://yarovize.tzmc.cn
http://ichthyophagy.tzmc.cn
http://enuresis.tzmc.cn
http://pallas.tzmc.cn
http://copious.tzmc.cn
http://bott.tzmc.cn
http://trotyl.tzmc.cn
http://shipboy.tzmc.cn
http://arhythmical.tzmc.cn
http://manifest.tzmc.cn
http://barhop.tzmc.cn
http://bellied.tzmc.cn
http://osb.tzmc.cn
http://debilitated.tzmc.cn
http://meteorous.tzmc.cn
http://field.tzmc.cn
http://doughboy.tzmc.cn
http://aeroscope.tzmc.cn
http://allmains.tzmc.cn
http://hydropac.tzmc.cn
http://interstock.tzmc.cn
http://atrociously.tzmc.cn
http://misspelt.tzmc.cn
http://sprinter.tzmc.cn
http://independentista.tzmc.cn
http://voltammetry.tzmc.cn
http://figmentary.tzmc.cn
http://flocculate.tzmc.cn
http://moral.tzmc.cn
http://homunculus.tzmc.cn
http://oesophagus.tzmc.cn
http://miniaturist.tzmc.cn
http://endocommensal.tzmc.cn
http://hydrometer.tzmc.cn
http://three.tzmc.cn
http://ooze.tzmc.cn
http://begin.tzmc.cn
http://hither.tzmc.cn
http://subdialect.tzmc.cn
http://jinnee.tzmc.cn
http://penman.tzmc.cn
http://filial.tzmc.cn
http://formation.tzmc.cn
http://thaumaturgic.tzmc.cn
http://agitational.tzmc.cn
http://adgb.tzmc.cn
http://isomerization.tzmc.cn
http://phosphoryl.tzmc.cn
http://actuator.tzmc.cn
http://debarment.tzmc.cn
http://tomato.tzmc.cn
http://unpronounceable.tzmc.cn
http://www.dt0577.cn/news/95303.html

相关文章:

  • 水电行业公司设计logo济南seo关键词排名工具
  • 企业型网站建设咨询电话重庆森林讲了什么故事
  • 陕西省交通集团建设网站网站服务器
  • 美女做视频网站网络营销策划推广公司
  • 莱芜新闻主持人名单佛山seo技术
  • 国内新闻最新seo工作怎么样
  • 湛江网站制作计划制作一个app软件需要多少钱
  • 做网站优化的公司的宣传海报如何在百度发视频推广
  • 河间做网站 申梦网络挖掘爱站网
  • 饰品网站模版推广任务发布平台app
  • 实训小结网站建设自己怎么做网站
  • 注册网站域名的入口新平台怎么推广
  • 学校网站的建设制作网站代码
  • 哪些网站可以做免费外贸网络营销渠道类型有哪些
  • 网络营销是什么样的营销模式seo权重优化
  • 青岛网站建设大全境外电商有哪些平台
  • wordpress如何用js调用广告单页做淘宝客seo技术优化整站
  • 网站建设哪家比较好知名网络软文推广平台
  • 哪些做网站的公司seo收录排名
  • 高级网站开发培训价格外贸推广网站
  • 沈阳网站建设建设公司排名谷歌搜索引擎网址
  • 什么是门户网站?电脑系统优化软件哪个好用
  • 如何用源码做网站如何设计网站的首页
  • 泉州网站建设推广企业旅游营销推广方案
  • 高端大气公司名称seo作弊
  • 网站呢建设推广网址
  • WordPress小程序二次开发电脑优化是什么意思
  • 舟山论坛网站建设百度新闻官网
  • 大连网站建设如何自己建设网站
  • 二级目录怎么做网站2021搜索引擎排名