The pointed to type of the pointer has nothing to do with the value pointer you want to print. If you want to print a value pointer as a number (e.g. the address at which that value is stored in& memory), you must first convert that pointer into an integer, so you can use a number printing approach. This is done inside the printf(3)
function, when you specify a pointer value (no matter what type it points to) in the format, with %p
format specifier.
#include<stdio.h>
int main()
{
int a=5;
printf("The address of a is: %p\n", &a);
printf("and the value of a is: %d\n", a);
return 0;
}
On execution, you'll get something similar to this:
$ pru
The address of a is: 0x7fffffffe3bc
and the value of a is: 5
$ _