All About %p in C Programming

All About %P In C Programming

There is a variety of format specifiers in C, every of which serves totally different capabilities and functions. This article will give attention to discussing the %p format specifier. This one is commonly used to print the info of the pointer kind.

What Is %p In C?

A format specifier comes in the type of a string, which is employed in the enter and output capabilities. Their codecs are decided by the format string.

All format specifiers begin with a % character. The %p format specifier works by printing a pointer’s worth in C programming. In this perform, the P programming language is used to mannequin and specify any protocols in event-driven purposes.

It additionally addresses the asynchronous computation’s challenges, together with Heisenbugs and asynchrony. For this purpose, the %p specifier works with a pointer whereas writing a C code. This one can be utilized with the printf() perform as others do.



void important() 


    int i=100;


    int *pointer = &i;








In this instance, you have to use the int i=100 to initialize the i integer variable. Then, it’s time to print this integer worth, which is 100 now. Here, create a pointer pointing in direction of the i tackle.

In the subsequent line, the pointer is printed with the %p specifier contained in the print() perform. You will get the pointer worth at 000000000064 as 100 will seemingly develop into 64 in hexadecimal.

READ :  [Solved] Halcon & C# Error: HalconDotNet.HOperatorException:“HALCON error #5190: Invalid window parameter in op

%p And Other Format Specifiers


%p is beneficial in printing the pointer worth whereas %x works by printing the hexadecimal ones. There wouldn’t be any main distinction in the event you print values with these two specifiers.

The distinction will typically come up in the kind of values. %p pints main zeros whereas %x doesn’t.



important() {

   int x = 59;

   printf("Value using %%p: %pn", x);

   printf("Value using %%x: %xn", x);



Value utilizing %p: 000000000000003B

Value utilizing %x: 3b


The u% format specifier is commonly executed to fetch values from a variable’s tackle. This variable tends to have an unsigned decimal integer in its reminiscence. For this purpose, it would print the unsigned variable in the printf() perform.


You can implement this format specifier to symbolize integer values. In the printf() perform, it prints the included integer worth in the variable.


Its important perform is to symbolize fractional values. Within the printf() perform, %f prints all floating or fractional values in the variable.


%c works by representing and printing characters in a variable.


As could be hinted from the s character, this one represents and prints strings in the character array variable.


This final format specifier represents lengthy integer values and prints them in the variable.

READ :  Will exFAT work on Raspberry Pi?


The article has launched you to the %d format specifier in C programming along with different specifiers. Each offers with several types of worth. Thus, you need to select an acceptable one.

Leave a Reply

Your email address will not be published. Required fields are marked *