Skip to content

Instantly share code, notes, and snippets.

@gnufs
Created November 21, 2010 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnufs/708907 to your computer and use it in GitHub Desktop.
Save gnufs/708907 to your computer and use it in GitHub Desktop.
pointer fun
#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