Created
July 18, 2014 22:52
-
-
Save rennex/e1359e69c619b2f7e7ca to your computer and use it in GitHub Desktop.
silly pointer math experiments
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 <stdio.h> | |
int main(void) { | |
long x = ""-""; | |
char *y = "foo"; | |
char *z = "foo"; | |
printf("null is %p, x is %ld\n", NULL, x); | |
printf("y is %p, z is %p\n", y, z); | |
return 0; | |
} | |
/* | |
I compiled this with gcc 4.7.2, and it prints: | |
null is (nil), x is 0 | |
y is 0x400624, z is 0x400624 | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment