当前位置:网站首页>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 */
边栏推荐
- VR全景婚礼,帮助新人记录浪漫且美好的场景
- Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
- This article discusses the memory layout of objects in the JVM, as well as the principle and application of memory alignment and compression pointer
- SQL statement optimization, order by desc speed optimization
- Flet教程之 13 ListView最常用的滚动控件 基础入门(教程含源码)
- MySQL 8 sub database and table backup database shell script
- Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
- In terms of byte measurement with an annual salary of 30W, automated testing can be learned in this way
- 中移动、蚂蚁、顺丰、兴盛优选技术专家,带你了解架构稳定性保障
- Compilation principle - top-down analysis and recursive descent analysis construction (notes)
猜你喜欢
Stealing others' vulnerability reports and selling them into sidelines, and the vulnerability reward platform gives rise to "insiders"
Distinguish between basic disk and dynamic disk RAID disk redundant array
C语言通过指针交换两个数
Today in history: the mother of Google was born; Two Turing Award pioneers born on the same day
Alibaba brand data bank: introduction to the most complete data bank
Jerry's updated equipment resource document [chapter]
【Swoole系列2.1】先把Swoole跑起来
78 岁华科教授逐梦 40 载,国产数据库达梦冲刺 IPO
node の SQLite
10 advanced concepts that must be understood in learning SQL
随机推荐
Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
STM32 key state machine 2 - state simplification and long press function addition
Codeforces Round #803 (Div. 2)
OpenEuler 会长久吗
传统家装有落差,VR全景家装让你体验新房落成效果
The solution that flutterweb browser cannot be rolled back after refreshing
DNS hijacking
Alertmanager sends the alarm email and specifies it as the Alibaba mailbox of the company
推荐好用的后台管理脚手架,人人开源
sql语句优化,order by desc速度优化
队列的实现
Video fusion cloud platform easycvr adds multi-level grouping, which can flexibly manage access devices
1700C - Helping the Nature
The easycvr authorization expiration page cannot be logged in. How to solve it?
Selected technical experts from China Mobile, ant, SF, and Xingsheng will show you the guarantee of architecture stability
Jerry's watch reading setting status [chapter]
Easy introduction to SQL (1): addition, deletion, modification and simple query
Distinguish between basic disk and dynamic disk RAID disk redundant array
adb常用命令
QT中Model-View-Delegate委托代理机制用法介绍