Created
November 21, 2010 17:08
-
-
Save gnufs/708907 to your computer and use it in GitHub Desktop.
pointer fun
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> | |
/* pointer fun */ | |
main() { | |
int x = 81; | |
int y; | |
printf("The adress of x is %p\n", &x); | |
printf("The value of x is %d\n", *&x); | |
printf("The address of y is %p\n", &y); | |
printf("The value of y is %d\n", *&y); | |
printf("The address distance between x and y is %d\n", (&x - &y)); | |
fiddle(&x, &y); | |
printf("After fiddling, the value of x is %d\n", *&x); | |
} | |
fiddle(int *p1, int *p2) { | |
*p1 = *p1 + 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment