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

边栏推荐
- 虚拟机VirtualBox和Vagrant安装
- Kill -9 system call used by PID to kill process
- Jerry's setting currently uses the dial. Switch the dial through this function [chapter]
- 面试突击63:MySQL 中如何去重?
- 趣-关于undefined的问题
- How to output special symbols in shell
- 基本磁盘与动态磁盘 RAID磁盘冗余阵列区分
- Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
- 李书福为何要亲自挂帅造手机?
- STM32按键状态机2——状态简化与增加长按功能
猜你喜欢

Pytest learning ----- pytest confitest of interface automation test Py file details

带你穿越古罗马,元宇宙巴士来啦 #Invisible Cities

Windows连接Linux上安装的Redis

JMeter interface test response data garbled

Pourquoi Li shufu a - t - il construit son téléphone portable?

Compilation principle - top-down analysis and recursive descent analysis construction (notes)

Reppoints: advanced order of deformable convolution

Interesting - questions about undefined

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

std::true_ Type and std:: false_ type
随机推荐
Pytorch extract middle layer features?
Codeforces Round #803 (Div. 2)
D binding function
[introduction to MySQL] the first sentence · first time in the "database" Mainland
Jerry's updated equipment resource document [chapter]
High precision operation
第三季百度网盘AI大赛盛夏来袭,寻找热爱AI的你!
SQL statement optimization, order by desc speed optimization
After entering Alibaba for the interview and returning with a salary of 35K, I summarized an interview question of Alibaba test engineer
关于这次通信故障,我想多说几句…
JMeter interface test response data garbled
Markdown grammar - better blogging
Principle and usage of extern
Redis的五种数据结构
虚拟机VirtualBox和Vagrant安装
推荐好用的后台管理脚手架,人人开源
FMT open source self driving instrument | FMT middleware: a high real-time distributed log module Mlog
Cool Lehman has a variety of AI digital human images to create a vr virtual exhibition hall with a sense of technology
Summary of Android interview questions of Dachang in 2022 (I) (including answers)
J'aimerais dire quelques mots de plus sur ce problème de communication...