What is %p in C?

%p is a format specifier in C programming language. It is used to print the pointer type data. It prints the memory address of the variable pointed by the pointer in hexadecimal form.

In 64 bit systems the pointers are of 8 bytes. So, the full hexadecimal representation is: 0000000000000055.

Let’s take an example


#include <stdio.h>

int main() {
	int a = 50;
   	int *p = &x;        //assigning the address of the variable to the pointer
   	printf("The address is: %p and the value is %d", p, *p);


The address is: 0x7ffc3d405e14 and the value is 50

The %p prints the address of the variable x in hexadecimal format and the %d prints the value at the address of the pointer variable which is 50.

Follow Us

You Missed

Also Checkout