Created
July 1, 2012 14:22
-
-
Save micolous/3028569 to your computer and use it in GitHub Desktop.
pointer arithmatic
This file contains 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
a (value) = 42 | |
a (addr) = 80484B0FFCEBB78 | |
incrementing... | |
a (value) = -3228804 | |
a (addr) = 80484B0FFCEBB7C |
This file contains 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> | |
// note: assumes 64-bit system | |
int main(int argc, char** argv) { | |
int v = 42; | |
int* a = &v; | |
printf("a (value) = %d\n", *a); | |
printf("a (addr) = %llX\n", a); | |
printf("\nincrementing...\n"); | |
a++; | |
printf("a (value) = %d\n", *a); | |
printf("a (addr) = %llX\n", a); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment