The %p
format specifier is used for printing the value of a pointer in C. This phenomenon is showed clearly in the coding example below.
#include<stdio.h>
void main()
{
int i=100;
printf("%d\n",i);
int *pointer = &i;
printf("%p\n",i);
printf("%p",pointer);
}
Output:
100
0000000000000064
000000000062FE14
In the above code, we first initialize the integer variable i
with int i=100;
and print the integer value of i
, which is 100
. Then we created the pointer pointer
that points towards the address of i
.