Here's the output of your program on my system:
-12115289320x7ffeb7c9891c
The two outputs are jammed together on one line, making it difficult to tell which is which.
Adding newlines to the output, I get:
344225740
0x7ffc148477cc
(There's no guarantee that a variable will have the same address from one run of a program to the next, and some systems deliberately change memory allocations.)
The %d format specifier requires an argument of type int. The correct format specifier for a pointer value is %p, and it requires an argument of type void*. Using inconsistent types, as you've done in your program, causes undefined behavior. At best, on many systems pointers are 64 bits and int is 32 bits, so %d can't possibly show an entire pointer value. It might show part of the pointer value, it might show garbage, or it might crash.
The %p format typically uses hexadecimal, but the format is implementation-defined.
Here's a corrected version of your program:
#include <stdio.h>
int main(void)
{
int a = 5;
int *ptra = &a;
printf("%p\n", (void*)&a);
printf("%p\n", (void*)ptra);
}
and the output on my system:
0x7ffd62a733ec
0x7ffd62a733ec
You'll see different output, but the two lines should match each other.
Note: void main() is incorrect; the correct declaration is int main(void).
%pfor both printfs and you should get the correct result.%dis undefined behavior. In other words: It may print any value. Always use%pfor pointersvoid*.%pspecifically requires avoid*argument, not a pointer of any type.