%p expects the address of something (or a pointer). You specify the value of the variable i instead of the address. Use
printf("%p",(void*)&i);
instead
printf("%p",i);
and GCC will compile the program without warning, and it will print the address where i saved when it starts. Ampersand ( & ) is the address of the operator and gives the address of the variable. A cast is also needed because the %p format specifier expects an argument of type void* , while &i is of type int* .
If you want the variable value to be printed, use
printf("%d",i);
Using the wrong format specifier will result in UB (Undefined Behavior)
source share