当前位置:网站首页>Comparative examples of C language pointers *p++, * (p++), * ++p, * (++p), (*p) + +, +(*p)
Comparative examples of C language pointers *p++, * (p++), * ++p, * (++p), (*p) + +, +(*p)
2022-07-06 18:06:00 【The way of growth of Peng】
//C Language pointer *p++、*(p++)、*++p、*(++p)、(*p)++、++(*p) Comparative examples
#include<stdio.h>
int main(){
int a[] = {
10,20,30,40,50};
int *p;
p = a;
printf("*p:%d\n",*p);// The initial position is pointing a[0]
printf("*p++:%d\n",*p++);// here P Or point to a[0], Output finished a[0] The post pointer address automatically adds one to point to the next position ( That is to say a[1] The location of )
printf("*(p++):%d\n",*(p++));// Now point to a[1]. Output finished a[1] The post pointer address automatically adds one to point to the next position ( That is to say a[2] The location of )
printf("*++p:%d\n",*++p);// The pointer now points to a[2] The location of . The pointer address first adds one to point to the next position ( That is to say a[3] The location of ) Then the output
printf("*(++p):%d\n",*(++p));// The pointer now points to a[3] The location of . The pointer address first adds one to point to the next position ( That is to say a[4] The location of ) Then the output
printf("(*p)++:%d\n",(*p)++);// The pointer now points to a[4] The location of . First, the output a[4] Then add one to the value of this address ( That is to say a[4] From 50 become 51).
printf("++(*p):%d\n",++(*p));// here a[4] The value of is already 51 了 . First pair a[4] The value of is increased by one ( That is to say a[4] From 51 become 52) Then the output .
return 0;
}
/* summary : *(p++) and *p++ Equivalent *++p and *(++p) Equivalent */
边栏推荐
- Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
- SQL statement optimization, order by desc speed optimization
- sql语句优化,order by desc速度优化
- Kill -9 system call used by PID to kill process
- Unity tips - draw aiming Center
- Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
- 从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
- 第三季百度网盘AI大赛盛夏来袭,寻找热爱AI的你!
- Insert dial file of Jerry's watch [chapter]
- 队列的实现
猜你喜欢
关于这次通信故障,我想多说几句…
Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
Appium automated test scroll and drag_ and_ Drop slides according to element position
Declval (example of return value of guidance function)
J'aimerais dire quelques mots de plus sur ce problème de communication...
队列的实现
10 advanced concepts that must be understood in learning SQL
模板于泛型编程之declval
基于STM32+华为云IOT设计的智能路灯
Jerry's access to additional information on the dial [article]
随机推荐
开源与安全的“冰与火之歌”
Pytest learning ----- detailed explanation of the request for interface automation test
Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
Unity particle special effects series - treasure chest of shining stars
容器里用systemctl运行服务报错:Failed to get D-Bus connection: Operation not permitted(解决方法)
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
1700C - Helping the Nature
编译原理——自上而下分析与递归下降分析构造(笔记)
递归的方式
Codeforces Round #803 (Div. 2)
std::true_type和std::false_type
MSF横向之MSF端口转发+路由表+SOCKS5+proxychains
[Android] kotlin code writing standardization document
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
Getting started with pytest ----- allow generate report
Windows连接Linux上安装的Redis
Getting started with pytest ----- test case rules
带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)