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

边栏推荐
- 酷雷曼多种AI数字人形象,打造科技感VR虚拟展厅
- Markdown grammar - better blogging
- Redis的五种数据结构
- There is a gap in traditional home decoration. VR panoramic home decoration allows you to experience the completion effect of your new house
- F200 - UAV equipped with domestic open source flight control system based on Model Design
- The shell generates JSON arrays and inserts them into the database
- 1700C - Helping the Nature
- 基于STM32+华为云IOT设计的智能路灯
- Jerry's watch deletes the existing dial file [chapter]
- Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
猜你喜欢

Reppoints: advanced order of deformable convolution

1700C - Helping the Nature

【.NET CORE】 请求长度过长报错解决方案

开源与安全的“冰与火之歌”

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

Unity particle special effects series - treasure chest of shining stars

Pytest learning ----- detailed explanation of the request for interface automation test

Distinguish between basic disk and dynamic disk RAID disk redundant array

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

关于这次通信故障,我想多说几句…
随机推荐
TCP packet sticking problem
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
Easy introduction to SQL (1): addition, deletion, modification and simple query
面试突击62:group by 有哪些注意事项?
递归的方式
ASEMI整流桥DB207的导通时间与参数选择
Pourquoi Li shufu a - t - il construit son téléphone portable?
There is a gap in traditional home decoration. VR panoramic home decoration allows you to experience the completion effect of your new house
Scratch epidemic isolation and nucleic acid detection Analog Electronics Society graphical programming scratch grade examination level 3 true questions and answers analysis June 2022
Jerry's updated equipment resource document [chapter]
8位MCU跑RTOS有没有意义?
DNS hijacking
Windows连接Linux上安装的Redis
STM32 key state machine 2 - state simplification and long press function addition
Flet教程之 13 ListView最常用的滚动控件 基础入门(教程含源码)
Interesting - questions about undefined
2019 Alibaba cluster dataset Usage Summary
最新财报发布+天猫618双榜第一,耐克蓄力领跑下个50年
编译原理——自上而下分析与递归下降分析构造(笔记)
How to use scroll bars to dynamically adjust parameters in opencv