Print the address or pointer for value in C Print the address or pointer for value in C c c

Print the address or pointer for value in C


To print address in pointer to pointer:

printf("%p",emp1)

to dereference once and print the second address:

printf("%p",*emp1)

You can always verify with debugger, if you are on linux use ddd and display memory, or just plain gdb, you will see the memory address so you can compare with the values in your pointers.


What you have is correct. Of course, you'll see that emp1 and item1 have the same pointer value.


I believe this would be most correct.

printf("%p", (void *)emp1);printf("%p", (void *)*emp1);

printf() is a variadic function and must be passed arguments of the right types. The standard says %p takes void *.