Please login

Prime

Prepinsta Prime

Video courses for company/skill based Preparation

(Check all courses)
Get Prime Video
Prime

Prepinsta Prime

Purchase mock tests for company/skill building

(Check all mocks)
Get Prime mock

What is the use of %p in C

What is the use of %p in C

What is %p in C Programming ?

%p is a format specifier in C Programming language, that is used to work with pointers while writing a code in C. Using %p with printf() we can print a pointer value in C programming. There are many other format specifiers in C, which you can study about on our Format Specifiers in C page, by clicking on the  button below

How to use %p in C Programming ?

%p is used with printf() similarly as other format specifiers are used, %p is particularly used for printing pointer type value. Lets see an example and understand the working of %p format specifier in C programming language

C code for using %p

#include <stdio.h>
int main()
{
    double ans=27.123;
    int *ptr = &ans; //declaring a pointer variable and storing the address of ans

    printf("The address of %f is %p \n",ans, ptr);

    return 0;
}