+ 2
Why it prints 0x1
2 Réponses
+ 7
%p used for pointers(memory address) so you should use &a.
Printf("%d %p" , a , &a );
output is 1 and hexadecimal value.
+ 3
%p is used to print the address of a variable and the argument must be a pointer to void. You are passing the value of 'a' directly, no address or cast.
It should be:
printf("%d %p\n", a, (void *)&a);
The way addresses are represented is implementation defined, but is usually a hexadecimal value which is why you got 0x1 for variable 'a'.