I understand %#x give the same effect of 0x%x and it meets POSIX standard. But people mention that some compilers do not support it. Is that true, any example?
Aside from perhaps some broken embedded-systems C libraries, the #
modifier should be universally supported. However %#x
and 0x%x
are not the same. They yield different results for the value 0, and the #
modifier will always print the x
in the same case as the hex digits (e.g. %#x
gives 0xa
and %#X
gives 0XA
) while using 0x%X
would allow you to have a lowercase x
and capital hex digits (much more visually pleasing, at least to me). As such, I find the #
modifier is rarely useful in practice.