Last active
April 13, 2016 23:55
-
-
Save guyhughes/a368af9988b8426d703d166187a10f5e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/wordsize.h> | |
#include <stdio.h> | |
#include <inttypes.h> | |
int main(void) | |
{ | |
uint64_t f, b, q, *foo, *bar, *qux; | |
foo=&f, bar=&b, qux=&q; | |
printf("size of a pointer is %d bytes\n",__WORDSIZE/8); | |
printf("size of an `int` is %d bytes\n",sizeof(f)); | |
*qux = (uint64_t) foo; | |
*bar = (uint64_t) qux; | |
*foo = (uint64_t) bar; | |
printf("qux = %"PRIu64"\n",qux); | |
printf("foo = %"PRIu64"\n",foo); | |
printf("bar = %"PRIu64"\n",bar); | |
printf("\n"); | |
printf("*qux = %"PRIu64"\n",*qux); | |
printf("*foo = %"PRIu64"\n",*foo); | |
printf("*bar = %"PRIu64"\n",*bar); | |
printf("\n"); | |
printf("&qux = %"PRIu64"\n",&qux); | |
printf("&foo = %"PRIu64"\n",&foo); | |
printf("&bar = %"PRIu64"\n",&bar); | |
printf("\n"); | |
printf("&qux == &foo → %d\n", &qux==&foo); | |
printf("*foo == &qux → %d\n" , (*foo == &qux) ); | |
printf("*bar == *qux → %d\n" , (*bar == *qux) ); | |
printf("\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
please assume 64 bit arch