What is %p modifier in C programming

%p modifier in C programming:

There are many different format specifiers in C programming language. %p is used to print the value of a pointer. A pointer can hold the address in C programming. So, it actually prints the memory address in the running machine.

The value it prints is in hexadecimal format.

Example program:

Let’s take a look at the below program:

#include <stdio.h>

int main() {
    int test = 10;
    
    int *testPointer = &test;
    
    printf("%p",testPointer);
    
    return 0;
}

If you run it, it will print something like below:

0x7ffe6ca9885c

i.e. the address of the variable test in hexadecimal format.

You might also like: