当前位置:网站首页>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 */
边栏推荐
- node の SQLite
- 第三季百度网盘AI大赛盛夏来袭,寻找热爱AI的你!
- Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
- Heavy! Ant open source trusted privacy computing framework "argot", flexible assembly of mainstream technologies, developer friendly layered design
- 趣-关于undefined的问题
- 8位MCU跑RTOS有没有意义?
- QT中Model-View-Delegate委托代理机制用法介绍
- Fleet tutorial 13 basic introduction to listview's most commonly used scroll controls (tutorial includes source code)
- HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
- 偷窃他人漏洞报告变卖成副业,漏洞赏金平台出“内鬼”
猜你喜欢
面试突击63:MySQL 中如何去重?
Declval (example of return value of guidance function)
IP, subnet mask, gateway, default gateway
Jerry's access to additional information on the dial [article]
编译原理——预测表C语言实现
Declval of template in generic programming
Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
李書福為何要親自掛帥造手機?
中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
Pytorch extract middle layer features?
随机推荐
C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
VR全景婚礼,帮助新人记录浪漫且美好的场景
FMT开源自驾仪 | FMT中间件:一种高实时的分布式日志模块Mlog
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
李书福为何要亲自挂帅造手机?
sql语句优化,order by desc速度优化
Getting started with pytest ----- allow generate report
[introduction to MySQL] the first sentence · first time in the "database" Mainland
MS-TCT:Inria&SBU提出用于动作检测的多尺度时间Transformer,效果SOTA!已开源!(CVPR2022)...
The difference between parallelism and concurrency
Alertmanager sends the alarm email and specifies it as the Alibaba mailbox of the company
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
Summary of Android interview questions of Dachang in 2022 (II) (including answers)
Introduction to the usage of model view delegate principal-agent mechanism in QT
面试突击63:MySQL 中如何去重?
Why should Li Shufu personally take charge of building mobile phones?
It doesn't make sense without a distributed gateway
Four processes of program operation
【Android】Kotlin代码编写规范化文档