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:
It's easy to solve if you cast the pointer to a long type. The problem is this won't work on all platforms as it assumes a pointer can fit inside a long, and that a pointer can be displayed in 16 characters (64 bits). This is however true on most platforms.
so it would become:
printf("%016lx", (unsigned long) ptr);