











What is the use of %p in C
What is %p in C Programming ?
%p is a format specifier in C Programming language, that is used to work with pointers while writing a code in C.

How to use %p in C Programming?
Usage
1. %p is used with printf() similarly as other format specifiers are used
2. %p is particularly used for printing pointer type value.
2. %p is particularly used for printing pointer type value.
Lets see an example and understand the working of %p format specifier in C programming language –
Example –
// %p prints the address in hexadecimal format #include<stdio.h> int main() { int var = 10; // declaring pointer variable to store address of var int *ptr = &var; printf("The address in decimal : %d \n", ptr); printf("The address in hexadecimal : %p \n", ptr); return 0; }
Output
The address in decimal : 1044715932 The address in hexadecimal : 0x7fff3e45199c
Login/Signup to comment