当前位置:网站首页>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 . . .
边栏推荐
- C declaration and initialization and assignment
- Extended operator of new features in ES6
- HCIP BGP
- 1985-2020 (8 Editions) global surface coverage download and introduction
- Wechat applet monitors sliding events on the screen
- Typescript from entry to mastery (XVIII) joint type and type protection
- 数据挖掘——关联分析基础介绍(上)
- SSL==证书相关概念
- [deep learning CPU (part outside) - virtual memory]
- Asp.net MVC中文件夹中的控制器如何跳转到根目录的控制器中?
猜你喜欢

How to understand clock cycle and formula CPU execution time = number of CPU clock cycles / dominant frequency

LDP -- label distribution protocol

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

Configmap配置与Secret加密

Alibaba Font Icon Library Usage and update methods
![[原理] 横向渗透的几种方式](/img/fc/2ef7dd6ebc5c0bd8f7d302d8b596d6.png)
[原理] 横向渗透的几种方式

内连接和左连接简单案例

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

1985-2020 (8 Editions) global surface coverage download and introduction

Interview essential! TCP classic 15 consecutive questions!
随机推荐
HCIP BGP
Why does the 20 bit address bus determine the storage space of 1MB
EMD empirical mode decomposition
OPENSQL快速学习
【C语言入门】ZZULIOJ 1031-1035
Several cases of word wrapping in div
CUB_ Visualization of key points in 200 bird dataset
[deep learning CPU (part outside) - virtual memory]
数据挖掘——关联分析例题代码实现(下)
2. Variables and scope
Since 2019, you must have stopped using this marketing strategy
Raft protocol - process demonstration
SQL window function
JS cookie usage
消费行业数字化升级成 “刚需”,weiit 新零售 SaaS 为企业赋能!
Big manufacturers finally can't stand "adding one second", and companies such as Microsoft, Google meta propose to abolish leap seconds
Shopify seller: EDM marketing should be combined with salesmartly to easily get the conversion rate
Solve the problem of garbled code when opening the project code in idea
力扣面试题17.04 消失的数字||260.只出现一次的数字(内含位运算知识点)
SFTP upload error: com.jcraft.jsch JSchException: connection is closed by foreign host