What's the proper use of printf to display pointers padded with 0s

后端 未结 9 2142
暖寄归人
暖寄归人 2021-01-31 14:32

In C, I\'d like to use printf to display pointers, and so that they line up properly, I\'d like to pad them with 0s.

My guess was that the proper way to do this was:

9条回答
  •  甜味超标
    2021-01-31 15:32

    I usually use %x to display pointers. I suppose that isn't portable to 64-bit systems, but it works fine for 32-bitters.

    I'll be interested in seeing what answers there are for portable solutions, since pointer representation isn't exactly portable.

提交回复
热议问题