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

边栏推荐
- pip install pyodbc : ERROR: Command errored out with exit status 1
- connection reset by peer
- 重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
- Virtual machine startup prompt probing EDD (edd=off to disable) error
- Solrcloud related commands
- 面试突击63:MySQL 中如何去重?
- Interpretation of Flink source code (I): Interpretation of streamgraph source code
- Binary search strategy
- Run xv6 system
- Xin'an Second Edition: Chapter 25 mobile application security requirements analysis and security protection engineering learning notes
猜你喜欢

Establishment of graphical monitoring grafana

Getting started with pytest ----- test case rules
![[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias](/img/03/ece7f7b28cd9caea4240635548c77f.jpg)
[elastic] elastic lacks xpack and cannot create template unknown setting index lifecycle. name index. lifecycle. rollover_ alias

Start job: operation returned an invalid status code 'badrequst' or 'forbidden‘

10 advanced concepts that must be understood in learning SQL

一体化实时 HTAP 数据库 StoneDB,如何替换 MySQL 并实现近百倍性能提升

Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices

中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障

【MySQL入门】第三话 · MySQL中常见的数据类型

分布式不来点网关都说不过去
随机推荐
EasyCVR授权到期页面无法登录,该如何解决?
[introduction to MySQL] the first sentence · first time in the "database" Mainland
学 SQL 必须了解的 10 个高级概念
Flink parsing (IV): recovery mechanism
开源与安全的“冰与火之歌”
Pytorch extract middle layer features?
SQL statement optimization, order by desc speed optimization
在一台服务器上部署多个EasyCVR出现报错“Press any to exit”,如何解决?
Wordcloud colormap color set and custom colors
Pytest learning ----- detailed explanation of the request for interface automation test
Quick start of Hongmeng system
Interpretation of Flink source code (II): Interpretation of jobgraph source code
adb常用命令
Automatic operation and maintenance sharp weapon ansible Playbook
Easy introduction to SQL (1): addition, deletion, modification and simple query
Awk command exercise
Run xv6 system
How to output special symbols in shell
scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
C # nanoframework lighting and key esp32