Last active
November 9, 2015 15:11
-
-
Save bzdgn/67c72a406b13c6a59a7f to your computer and use it in GitHub Desktop.
C Pointer Sample
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> | |
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