当前位置:网站首页>Pointer variables -printf%d and%p meaning
Pointer variables -printf%d and%p meaning
2022-07-29 04:00:00 【Xiaowa 123】
1. The value of the pointer variable is the address , The address is usually 16 Hexadecimal said
2.int a=1;
int* p=&a;
printf("%d\n",p); and printf("%p\n",p); What's the difference , The output is p Value ,%p Pointer variable p Stored in the a The address of is output in hexadecimal ,%d Is that so? p Stored in the a The address of is output in decimal form . The output is p Value , Don't understand it as %p, It's a p The address output of .
%p It is specially used for pointer variables , Output the value stored in the pointer variable , That is, the address of other variables , It's just output in hexadecimal form .
So there's another problem , since %p All are hexadecimal , Then use %x Not line? ?
%p It is specially used for pointer variables , The output is the address in hexadecimal form .%x Is to output variables in hexadecimal form , When you want to see what address is stored in the pointer variable , Just use %p.
Let's use the program to see the running results :
#include<stdio.h>
int main(void)
{
int a = 1;
int* p = &a;
printf("%d\n", p);
printf("%p\n", p);// This is the most correct , Pointer variables are collocated %p For the output
printf("%x\n", p);
printf("\n");
printf("%d\n", &a);
printf("%x\n", &a);
printf("%p\n", &a);// This is the most correct ,&a It's a pointer
return 0;
}13630412
00CFFBCC//%p
cffbcc
13630412
cffbcc
00CFFBCC//%p
Please press any key to continue . . .
边栏推荐
- 关于ALV格式控制部分的写法
- lodash库常用方法
- Data mining -- Introduction to the basis of association analysis (Part 1)
- SQL语句 关于字段转换怎么写
- 1. Header file - Comment - namespace - standard input / output stream
- Use case of arrow function of new features in ES6
- OPENSQL快速学习
- Flask framework operation database_ Add, delete, modify and query statements
- Several cases of word wrapping in div
- 关于双指针的思想总结
猜你喜欢

Interview essential! TCP classic 15 consecutive questions!

安装ros的laser_scan_matche库所遇到的问题(一)

What you see and think in Microsoft

Lvs+keepalived high availability deployment practical application

Connection broken by 'readtimc rt-443): read timed out (read timeout=l5)“)‘: /pac

nacos注册中心

Nacos registry

Malloc C language

Solve the problem of garbled code when opening the project code in idea

Is the browser multi process or single process?
随机推荐
Object array merges elements according to a field
OA项目之会议通知(查询&是否参会&反馈详情)
The output comparison function of Tim is introduced in detail through PWM breathing lamp and PWM controlled DC motor
消费行业数字化升级成 “刚需”,weiit 新零售 SaaS 为企业赋能!
Uni app internationalization
【深度学习CPU(番外篇)——虚拟内存】
小马智行进军前装量产,从自研域控制器入手?
After I get the winfrom specific control ID from the database, I need to find the corresponding control through this ID and assign a value to the text text of the control. What should I do
SSL==证书相关概念
JS cookie usage
What have I learned from 200 machine learning tools?
How fast does it take to implement a super simple programming language?
数据挖掘——关联分析基础介绍(上)
1. Header file - Comment - namespace - standard input / output stream
5年多工作经验,工资给15k,要是你,你会接受吗?
Typescript from getting started to mastering (XXII) namespace namespace (I)
BGP的基础配置---建立对等体、路由宣告
The digitalization of the consumer industry is upgraded to "rigid demand", and weiit's new retail SaaS empowers enterprises!
Wechat applet monitors sliding events on the screen
Lvs+keepalived high availability deployment practical application