当前位置:网站首页>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 */

边栏推荐
- The shell generates JSON arrays and inserts them into the database
- 中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
- Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
- Getting started with pytest ----- test case pre post, firmware
- Declval of template in generic programming
- Unity tips - draw aiming Center
- 推荐好用的后台管理脚手架,人人开源
- Mysqlimport imports data files into the database
- The difference between parallelism and concurrency
- 30 分钟看懂 PCA 主成分分析
猜你喜欢

RB157-ASEMI整流桥RB157

scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月

Four processes of program operation

How to solve the error "press any to exit" when deploying multiple easycvr on one server?

kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)

Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)

Smart street lamp based on stm32+ Huawei cloud IOT design

李書福為何要親自掛帥造手機?

std::true_ Type and std:: false_ type

F200——搭载基于模型设计的国产开源飞控系统无人机
随机推荐
《ASP.NET Core 6框架揭秘》样章发布[200页/5章]
kivy教程之在 Kivy 中支持中文以构建跨平台应用程序(教程含源码)
EasyCVR授权到期页面无法登录,该如何解决?
第三季百度网盘AI大赛盛夏来袭,寻找热爱AI的你!
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
Kivy tutorial: support Chinese in Kivy to build cross platform applications (tutorial includes source code)
从交互模型中蒸馏知识!中科大&美团提出VIRT,兼具双塔模型的效率和交互模型的性能,在文本匹配上实现性能和效率的平衡!...
F200——搭载基于模型设计的国产开源飞控系统无人机
How to solve the error "press any to exit" when deploying multiple easycvr on one server?
基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
面向程序员的精品开源字体
JMeter interface test response data garbled
Manifest of SAP ui5 framework json
重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
Nodejs 开发者路线图 2022 零基础学习指南
虚拟机VirtualBox和Vagrant安装
Will openeuler last long
STM32按键状态机2——状态简化与增加长按功能
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用