Where is `%p` useful with printf?

后端 未结 7 1441
鱼传尺愫
鱼传尺愫 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:56

    You cannot depend on %p displaying a 0x prefix. On Visual C++, it does not. Use %#p to be portable.

    0 讨论(0)
提交回复
热议问题