当前位置:网站首页>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 */
边栏推荐
- Shell input a string of numbers to determine whether it is a mobile phone number
- Pourquoi Li shufu a - t - il construit son téléphone portable?
- Awk command exercise
- J'aimerais dire quelques mots de plus sur ce problème de communication...
- MSF横向之MSF端口转发+路由表+SOCKS5+proxychains
- 1700C - Helping the Nature
- EasyCVR授权到期页面无法登录,该如何解决?
- Jielizhi obtains the currently used dial information [chapter]
- Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
- Optimization of middle alignment of loading style of device player in easycvr electronic map
猜你喜欢
F200 - UAV equipped with domestic open source flight control system based on Model Design
Pytorch extract middle layer features?
node の SQLite
8位MCU跑RTOS有没有意义?
OliveTin能在网页上安全运行shell命令(上)
Is it meaningful for 8-bit MCU to run RTOS?
中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
Appium automated test scroll and drag_ and_ Drop slides according to element position
Take you through ancient Rome, the meta universe bus is coming # Invisible Cities
关于这次通信故障,我想多说几句…
随机推荐
How to use scroll bars to dynamically adjust parameters in opencv
10 advanced concepts that must be understood in learning SQL
Interview shock 62: what are the precautions for group by?
第三季百度网盘AI大赛盛夏来袭,寻找热爱AI的你!
SAP UI5 框架的 manifest.json
Kill -9 system call used by PID to kill process
虚拟机VirtualBox和Vagrant安装
面试突击62:group by 有哪些注意事项?
Heavy! Ant open source trusted privacy computing framework "argot", flexible assembly of mainstream technologies, developer friendly layered design
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
李書福為何要親自掛帥造手機?
The solution that flutterweb browser cannot be rolled back after refreshing
QT中Model-View-Delegate委托代理机制用法介绍
Codeforces Round #803 (Div. 2)
微信为什么使用 SQLite 保存聊天记录?
Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
Shell input a string of numbers to determine whether it is a mobile phone number
The difference between parallelism and concurrency
FMT open source self driving instrument | FMT middleware: a high real-time distributed log module Mlog
Jerry's watch deletes the existing dial file [chapter]