, #include , , , int main() { , int x = 10; , int *px = &x; , , printf(DQthe value of x: %d\nDQ, x); , printf(DQthe address of x: %p\nDQ,&x); , printf(DQthe value of *px: %d\nDQ, *px); , printf(DQthe address of *px: %p\nDQ,&px); , , return 0; , } ,
, #include , int main() , { , /* Pointer of integer type, this can hold the , * address of a integer type variable. , */ , int *p; , , int var = 10; , , /* Assigning the address of variable var to the pointer , * p. The p can hold the address of var because var is , * an integer type variable. , */ , p= &var; , *p = 11; , printf(DQValue of variable var is: %dDQ, var); , printf(DQ\nValue of what *p is pointing to (var): %dDQ, *p); , printf(DQ\nAddress of variable var (&var) is: %pDQ, &var); , printf(DQ\nAddress of variable var (p) is: %pDQ, p); , printf(DQ\nAddress of pointer p is: %pDQ, &p); , return 0; , } , , output: , Value of variable var is: 11 , Value of what *p is pointing to (var): 11 , Address of variable var (&var) is: 0x7ffc2d7d33ac , Address of variable var (p) is: 0x7ffc2d7d33ac , Address of pointer p is: 0x7ffc2d7d33b0 , , ,
, #include , , int main() , { , , int a = 7, b ; , int *ptr; // Un-initialized Pointer , ptr = &a; // Stores address of a in ptr , b = *ptr; // Put Value at ptr in b , , printf(DQThe contents of b: %d\nDQ, b); , , return 0; , } , ,