Where is `%p` useful with printf?

后端 未结 7 1577
鱼传尺愫
鱼传尺愫 2020-11-27 03:10

After all, both these statements do the same thing...

int a = 10;
int *b = &a;
printf(\"%p\\n\",b);
printf(\"%08X\\n\",b);

For example

7条回答
  •  广开言路
    2020-11-27 03:33

    x is Unsigned hexadecimal integer ( 32 Bit )

    p is Pointer address

    See printf on the C++ Reference. Even if both of them would write the same, I would use %p to print a pointer.

提交回复
热议问题