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

边栏推荐
- 基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
- Flink parsing (V): state and state backend
- VR全景婚礼,帮助新人记录浪漫且美好的场景
- The solution to the left-right sliding conflict caused by nesting Baidu MapView in the fragment of viewpager
- Openharmony developer documentation open source project
- VR panoramic wedding helps couples record romantic and beautiful scenes
- Vscode replaces commas, or specific characters with newlines
- Pytest learning ----- pytest confitest of interface automation test Py file details
- 学 SQL 必须了解的 10 个高级概念
- Binary search strategy
猜你喜欢

Solr appears write Lock, solrexception: could not get leader props in the log

Concept and basic knowledge of network layering

TCP连接不止用TCP协议沟通

C # nanoframework lighting and key esp32

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

基本磁盘与动态磁盘 RAID磁盘冗余阵列区分

李书福为何要亲自挂帅造手机?

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

Yarn: unable to load file d:\programfiles\nodejs\yarn PS1, because running scripts is prohibited on this system

Solution qui ne peut pas être retournée après la mise à jour du navigateur Web flutter
随机推荐
[getting started with MySQL] fourth, explore operators in MySQL with Kiko
Summary of Android interview questions of Dachang in 2022 (II) (including answers)
Flink parsing (IV): recovery mechanism
The most complete tcpdump and Wireshark packet capturing practice in the whole network
Zen integration nails, bugs, needs, etc. are reminded by nails
Flet教程之 13 ListView最常用的滚动控件 基础入门(教程含源码)
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
Flink analysis (I): basic concept analysis
Pytest learning ----- pytest confitest of interface automation test Py file details
虚拟机启动提示Probing EDD (edd=off to disable)错误
酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
What is the reason why the video cannot be played normally after the easycvr access device turns on the audio?
【ASM】字节码操作 ClassWriter 类介绍与使用
一体化实时 HTAP 数据库 StoneDB,如何替换 MySQL 并实现近百倍性能提升
How to submit data through post
Reppoints: advanced order of deformable convolution
Pyspark operator processing spatial data full parsing (5): how to use spatial operation interface in pyspark
Easy introduction to SQL (1): addition, deletion, modification and simple query
Interpretation of Flink source code (I): Interpretation of streamgraph source code