Skip to content

Instantly share code, notes, and snippets.

@rennex
Created July 18, 2014 22:52
Show Gist options
  • Save rennex/e1359e69c619b2f7e7ca to your computer and use it in GitHub Desktop.
Save rennex/e1359e69c619b2f7e7ca to your computer and use it in GitHub Desktop.
silly pointer math experiments
#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