当前位置:网站首页>指针数组&数组指针
指针数组&数组指针
2022-07-17 05:08:00 【学会放下ta】
指针
是指内存的地址,指针变量只能储存地址
定义与使用:
int * a;
int b = 110;
a = &b;
其中a 等于 b的地址,*a等于b(的值)
指针与数组
int a[3]={
1,2,3};
a[2]与*(a+2)等效
数组名相当于一个指针变量
数组下标跟指针访问是等价的例如
int str[9]={
1,2,3,4,5,6,7,8,9};
str[3] == *(str+3) == 4
int *b;
b = &a[5];
b[-2] == *(b-2) == a[5-2] == 4
指针数组
本质是储存指针的数组
int *p[5];
根据运算符号的优先级可以知道上述运算顺序是:
int *(p[5]);即p先与[5]结合形成一个数组,类型自然就是前面的int *啦。
数组指针
本质是指向一个数组的指针
int a[5]={
1,2,3,4,5};
int (*p)[5];//他需要的是一个数组的地址,所以初始化注意
p = &a;
printf("%d\n",*(*p+1));//打印出的是2
下面是一个数组指针和指针数组的应用:
结果:
我还不是很熟练,写了几次才运行过。
边栏推荐
猜你喜欢

Parent components plus scoped sometimes affect child components

Implementation of synchronization interface of 6 libcurl based on libco

Distributed storage fastdfs

MySQL安装配置教程(超级详细)

ambari集群扩容节点+扩容服务操作

Cesium BIND Mouse Events and remove Mouse Events

循环赛制日程表问题

分布式存储-fastdfs

基于PaddleOCR解决文本检测训练模型与inference模型预测效果不一致的问题

用Flink SQL流化市场数据2:盘中风险价值
随机推荐
OpenDDS的QoS和自定义QoS(校时TimingQosPolicy)
聊聊写代码的20个反面教材
ambari集群扩容节点+扩容服务操作
Easypoi excel simple export
单臂路由配置
Common interview questions of operating system
Nacos配置管理
2020-11-10
What is the employment prospect of software testing? There is a large demand for talents and strong job stability
Excel导入长数据末尾变000
Use of log4j
[first launch in the whole network] one month later, we switched from MySQL dual master to master-slave
Online software testing training institutions lemon class and itest AI platform achieves strategic cooperation
聊聊并发编程的12种业务场景
GoFrame 错误处理的常用方法&错误码的使用
Round robin schedule problem
markdown笔记以及Typora相关快捷键
MySQL--存储和游标
mysql的缓存方案问题解决
Switch user mode, privileged mode, global mode, port mode