I just started reading up on pointers and memory addresses when I got curious about just how memory addresses are stored in pointers. Try compiling and running the simple function below to see how memory addresses are stored as hex values.
This file contains hidden or 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(){ | |
int x, *p; | |
x =10; | |
*p = &x; | |
printf("value of x: %d", x); | |
printf("address of x: %p", &x); | |
printf("printout of pointer p: %p", p); | |
printf("value at p: %d", *p); | |
return 0; | |
} |
No comments:
Post a Comment