What is the difference between %x and %p format specifier ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • radha gogia
    New Member
    • Feb 2015
    • 56

    What is the difference between %x and %p format specifier ?

    Code:
    int *p ;
    printf("%p" , p);
    This code printed 7EFDE000

    When I used the format specifier %x , then it printed 7efde000

    so its just changing the upper case letters to lower case letters , so then whats the basic difference between these two while printing address values ?
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    The %x is used for unsigned hexadecimal integers.

    The pointer is not a hexadecimal integer but the %p will display the address in the pointer in hexadecimal.

    Comment

    Working...