Home > Backend Development > C++ > body text

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

王林
Release: 2023-08-27 21:29:02
forward
2401 people have browsed it

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);
}
Copy after login

Output

The address is: 000000000022FE44, the value is 50
Copy after login

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!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template