I have a question regarding using intptr_t vs. long int. I\'ve observed that incrementing memory addresses (e.g. via manual pointer arithmetic) dif
You could make your life easier by using the p conversion specifier:
printf("%p\n", (void *)foo);
Also, the portable way to print a variable of type (u)intptr_t is to use the PRI*PTR macros from inttypes.h; the following is equivalent to using p on my platform (32-bit):
printf("%08" PRIxPTR "\n", (uintptr_t)(void *)foo);
The casts to void * are necessary for full portability, but can be omitted on platforms with uniform pointer representations.