17th Jun 2020, 4:25 PM
Muralikrishnan
Muralikrishnan - avatar
2 ответов
+ 7
%p used for pointers(memory address) so you should use &a. Printf("%d %p" , a , &a ); output is 1 and hexadecimal value.
17th Jun 2020, 4:56 PM
Eshan Gayanga
Eshan Gayanga - avatar
+ 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'.
17th Jun 2020, 5:02 PM
Gen2oo
Gen2oo - avatar