%P Format Specifier in C

This tutorial will discuss the %p format specifier in C#.

the %p Format Specifier in C

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.


void main() 
    int i=100;
    int *pointer = &i;



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.

In the next line, we printed the pointer value of i with the %p format specifier inside the print() function. The pointer value of i is 0000000000000064 because 100 becomes 64 in hexadecimal. After that, we printed the value inside the pointer with the %p format specifier.

DelftStack is a collective effort contributed by software geeks like you. If you like the article and would like to contribute to DelftStack by writing paid articles, you can check the write for us page.