Skip to content

Instantly share code, notes, and snippets.

@PkmX
Created January 17, 2015 12:54
Show Gist options
  • Save PkmX/a0073d4d7904137d9638 to your computer and use it in GitHub Desktop.
Save PkmX/a0073d4d7904137d9638 to your computer and use it in GitHub Desktop.
#include <stdint.h>
#include <inttypes.h>
#include <stdio.h>
int x = 0;
int main(void)
{
int y = 0;
// ok: 0x60098c 0x7ffffb53904c
printf("%p %p\n", (void*) &x, (void*) &y);
// ok: 60098c 7ffffb53904c
printf("%" PRIxPTR " %" PRIxPTR "\n", (intptr_t) &x, (intptr_t) &y);
// ill: 6293900 -78409652
printf("%d %d\n", (int) &x, (int) &y);
// ill: 0x60098c 0xfffffffffb53904c
printf("%p %p\n", (void*) ((int) &x), (void*) ((int) &y));
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment