Skip to content

Instantly share code, notes, and snippets.

@bzdgn
Last active November 9, 2015 15:11
Show Gist options
  • Save bzdgn/67c72a406b13c6a59a7f to your computer and use it in GitHub Desktop.
Save bzdgn/67c72a406b13c6a59a7f to your computer and use it in GitHub Desktop.
C Pointer Sample
#include <stdio.h>
int main()
{
/* a simple integer */
int i = 1234;
/* a pointer to an integer */
int * p = 0;
p = &i;
printf("Address of i : 0x%p\n", &i);
printf("Address p stores: 0x%p\n", p);
printf("****************************************\n");
printf("\n");
int j = *p;
printf("Content of j : %d\n", j);
printf("Content of *p : %d\n", *p);
printf("Content of *(&i): %d\n", *(&i));
*p = 5678;
j = *p;
printf("\n");
printf("After update with dereferencing operator\n");
printf("****************************************\n");
printf("Content of j : %d\n", j);
printf("Content of *p : %d\n", *p);
printf("Content of *(&i): %d\n", *(&i));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment