Where is `%p` useful with printf?

后端 未结 7 1579
鱼传尺愫
鱼传尺愫 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.

提交回复
热议问题