/* creat, initialize, assign, access a pointer
a program that creats an int var. with a hard-coded value.
assign that var's adr to a pointer var.
-display as output :
1.the adr of the ptr
2.the value of the ptr
3.the value of what the ptr is pointing to
*/
#include <stdio.h>
int main() {
int num = 31;
int *pnum = NULL; //create, initialize(X point to)
pnum = # //assign
printf("the adr of the ptr(adr of the ptr): %p\n\n", &pnum); // Dereference pnumb to get the value
printf("the adr of the num: %p\n", &num); //adr
printf("the adr of the num(adr stored in the ptr): %p\n", (void *)pnum);
printf("the adr of the num(adr stored in the ptr): %p\n\n", pnum); // Dereference pnumb to get the value
printf("Vl pointed to by the ptr: %d\n", *pnum); // Dereference pnumb to get the value
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: