Home >Backend Development >C++ >What is the use of '%p' in printf in C?

What is the use of '%p' in printf in C?

王林
王林forward
2023-08-27 21:29:022470browse

C 中 printf 中的“%p”有什么用?

In C language, we have seen different format specifiers. Here we will see another format specifier called %p. It is used to print pointer type data. Let's see an example to understand better.

Example

#include<stdio.h>
main() {
   int x = 50;
   int *ptr = &x;
   printf("The address is: %p, the value is %d", ptr, *ptr);
}

Output

The address is: 000000000022FE44, the value is 50

The above is the detailed content of What is the use of '%p' in printf in C?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete