string format for intptr_t and uintptr_t

That would be the following macros from inttypes.h:

For printf:
PRIdPTR PRIiPTR PRIoPTR PRIuPTR PRIxPTR PRIXPTR

For scanf:
SCNdPTR SCNiPTR SCNoPTR SCNuPTR SCNxPTR

Usage example:

uintptr_t p = SOME_VALUE;
printf("Here's a pointer for you: %" PRIxPTR "\n", p);

Leave a Comment