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

边栏推荐
- Grafana 9 正式发布,更易用,更酷炫了!
- Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
- Awk command exercise
- 【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
- 中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
- 酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
- It doesn't make sense without a distributed gateway
- TCP connection is more than communicating with TCP protocol
- Xin'an Second Edition: Chapter 26 big data security demand analysis and security protection engineering learning notes
- Huawei certified cloud computing hica
猜你喜欢

Flink analysis (II): analysis of backpressure mechanism

FlutterWeb瀏覽器刷新後無法回退的解决方案

SAP UI5 框架的 manifest.json

Flink analysis (I): basic concept analysis

基于STM32+华为云IOT设计的智能路灯

2021-03-22 "display login screen during recovery" can't be canceled. The appearance of lock screen interface leads to the solution that the remotely connected virtual machine can't work normally

pip install pyodbc : ERROR: Command errored out with exit status 1

Kali2021 installation and basic configuration

偷窃他人漏洞报告变卖成副业,漏洞赏金平台出“内鬼”

Summary of Android interview questions of Dachang in 2022 (II) (including answers)
随机推荐
Spark calculation operator and some small details in liunx
开源与安全的“冰与火之歌”
The art of Engineering (1): try to package things that do not need to be exposed
Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
PySpark算子处理空间数据全解析(5): 如何在PySpark里面使用空间运算接口
Flink parsing (V): state and state backend
Kernel link script parsing
Automatic operation and maintenance sharp weapon ansible Foundation
The solution to the left-right sliding conflict caused by nesting Baidu MapView in the fragment of viewpager
Manifest of SAP ui5 framework json
VR panoramic wedding helps couples record romantic and beautiful scenes
Pytest learning ----- detailed explanation of the request for interface automation test
微信小程序获取手机号
Pytest learning ----- pytest operation mode and pre post packaging of interface automation testing
【Elastic】Elastic缺少xpack无法创建模板 unknown setting index.lifecycle.name index.lifecycle.rollover_alias
BearPi-HM_ Nano development board "flower protector" case
How to solve the error "press any to exit" when deploying multiple easycvr on one server?
Alertmanager sends the alarm email and specifies it as the Alibaba mailbox of the company
Flink analysis (II): analysis of backpressure mechanism
Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices