Home >Backend Development >C++ >What is the difference between %p and %x in C/C++?
Here we will see the difference between %p and %x in C or C. %p is used to print pointer values, %x is used to print hexadecimal values. Although pointers can also be displayed using %u or %x. If we want to print some value using %p and %x then we won't feel any major difference. The only difference that can be noticed is that %p will print some leading zeros, but %x will not.
#include<stdio.h> main() { int x = 59; printf("Value using %%p: %p\n", x); printf("Value using %%x: %x\n", x); }
Value using %p: 000000000000003B Value using %x: 3b
The above is the detailed content of What is the difference between %p and %x in C/C++?. For more information, please follow other related articles on the PHP Chinese website!