Search code examples
cpointersmemory-addressdereferencepointer-address

What is the memory address and pointer address in the following image?


I was just playing with pointer. And I understood only line 5, 6 and 10, 11 completely. What I want to know is which one is the address of pointer here? And what does line 7 and 14 implies? Additionally what is the meaning of %p, using this code as reference.

output is aligned with line

enter image description here


Solution

  • firstly line 7: is a error because you try to print a pointer value but you pass to him a int value 'i' that well print a addressee memory correspond to that int in hex(base 16). For the line 14 : (*p) it's the same thing you pass a int type to pointer because *p return the value who is stocked in the pointer that why it's well print again the address in hex to more understand change the value of i to 15 or higher it well give you his value on hex . The address of pointer it's (&p) because &: mean adress so & of pointer it's the last one line 15 .