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

边栏推荐
- How to use scroll bars to dynamically adjust parameters in opencv
- Summary of Android interview questions of Dachang in 2022 (I) (including answers)
- How to solve the error "press any to exit" when deploying multiple easycvr on one server?
- Interview assault 63: how to remove duplication in MySQL?
- Kill -9 system call used by PID to kill process
- 10 advanced concepts that must be understood in learning SQL
- Easy introduction to SQL (1): addition, deletion, modification and simple query
- Getting started with pytest ----- test case rules
- 编译原理——预测表C语言实现
- Interesting - questions about undefined
猜你喜欢

Introduction to the usage of model view delegate principal-agent mechanism in QT

Interesting - questions about undefined

Interview shock 62: what are the precautions for group by?

Declval of template in generic programming

FMT open source self driving instrument | FMT middleware: a high real-time distributed log module Mlog

C语言指针*p++、*(p++)、*++p、*(++p)、(*p)++、++(*p)对比实例

SQL statement optimization, order by desc speed optimization

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

Zen integration nails, bugs, needs, etc. are reminded by nails

sql语句优化,order by desc速度优化
随机推荐
Interview shock 62: what are the precautions for group by?
10 advanced concepts that must be understood in learning SQL
重磅硬核 | 一文聊透对象在 JVM 中的内存布局,以及内存对齐和压缩指针的原理及应用
Jielizhi obtains the customized background information corresponding to the specified dial [chapter]
Declval of template in generic programming
Release of the sample chapter of "uncover the secrets of asp.net core 6 framework" [200 pages /5 chapters]
scratch疫情隔离和核酸检测模拟 电子学会图形化编程scratch等级考试三级真题和答案解析2022年6月
历史上的今天:Google 之母出生;同一天诞生的两位图灵奖先驱
Jerry's watch deletes the existing dial file [chapter]
李书福为何要亲自挂帅造手机?
Getting started with pytest ----- allow generate report
Easy introduction to SQL (1): addition, deletion, modification and simple query
Transfer data to event object in wechat applet
Summary of Android interview questions of Dachang in 2022 (I) (including answers)
Today in history: the mother of Google was born; Two Turing Award pioneers born on the same day
重磅!蚂蚁开源可信隐私计算框架“隐语”,主流技术灵活组装、开发者友好分层设计...
Compilation principle - top-down analysis and recursive descent analysis construction (notes)
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
Jerry's watch reading setting status [chapter]
OliveTin能在网页上安全运行shell命令(上)