当前位置:网站首页>C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
2022-07-06 09:43:00 【芣苢的成长之路】
//C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例
#include<stdio.h>
int main(){
int a[] = {
10,20,30,40,50};
int *p;
p = a;
printf("*p:%d\n",*p);//初始位置是指向a[0]
printf("*p++:%d\n",*p++);//此时P还是指向a[0],输出完a[0]后指针地址自加一指向下一个位置(也就是a[1]的位置)
printf("*(p++):%d\n",*(p++));//此时指向a[1]。输出完a[1]后指针地址自加一指向下一个位置(也就是a[2]的位置)
printf("*++p:%d\n",*++p);//指针此时指向a[2]的位置。指针地址先自加一指向下一个位置(也就是a[3]的位置)再输出
printf("*(++p):%d\n",*(++p));//指针此时指向a[3]的位置。指针地址先自加一指向下一个位置(也就是a[4]的位置)再输出
printf("(*p)++:%d\n",(*p)++);//指针此时指向a[4]的位置。先输出a[4]后再对这个地址的值进行自加一(也就是a[4]的值从50变成51)。
printf("++(*p):%d\n",++(*p));//此时a[4]的值已经是51了。先对a[4]的值自加一(也就是a[4]的值从51变成52)再输出。
return 0;
}
/* 总结: *(p++) 和 *p++ 等价 *++p 和 *(++p) 等价 */
边栏推荐
- The art of Engineering (2): the transformation from general type to specific type needs to be tested for legitimacy
- Flink parsing (IV): recovery mechanism
- 全网最全tcpdump和Wireshark抓包实践
- How uipath determines that an object is null
- Xin'an Second Edition: Chapter 24 industrial control safety demand analysis and safety protection engineering learning notes
- What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
- Vscode matches and replaces the brackets
- 2022年大厂Android面试题汇总(二)(含答案)
- sql语句优化,order by desc速度优化
- OliveTin能在网页上安全运行shell命令(上)
猜你喜欢
BearPi-HM_ Nano development environment
Distinguish between basic disk and dynamic disk RAID disk redundant array
OliveTin能在网页上安全运行shell命令(上)
FlutterWeb瀏覽器刷新後無法回退的解决方案
李书福为何要亲自挂帅造手机?
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
pip install pyodbc : ERROR: Command errored out with exit status 1
Solr appears write Lock, solrexception: could not get leader props in the log
Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘
随机推荐
Unity粒子特效系列-闪星星的宝箱
遠程代碼執行滲透測試——B模塊測試
Summary of study notes for 2022 soft exam information security engineer preparation
C # nanoframework lighting and key esp32
OpenCV中如何使用滚动条动态调整参数
MySQL 8 sub database and table backup database shell script
Reppoints: advanced order of deformable convolution
Automatic operation and maintenance sharp weapon ansible Foundation
Interpretation of Flink source code (II): Interpretation of jobgraph source code
Error: Publish of Process project to Orchestrator failed. The operation has timed out.
Flink parsing (III): memory management
Summary of Android interview questions of Dachang in 2022 (II) (including answers)
Distributed (consistency protocol) leader election (dotnext.net.cluster implements raft election)
C version selenium operation chrome full screen mode display (F11)
Smart street lamp based on stm32+ Huawei cloud IOT design
Sqoop I have everything you want
Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
Zen integration nails, bugs, needs, etc. are reminded by nails
The easycvr platform reports an error "ID cannot be empty" through the interface editing channel. What is the reason?
EasyCVR平台通过接口编辑通道出现报错“ID不能为空”,是什么原因?