When you intend to print the memory address of any variable or a pointer, using %d
won't do the job and will cause some compilation errors, because you're trying to print out a number instead of an address, and even if it does work, you'd have an intent error, because a memory address is not a number. the value 0xbfc0d878
is surely not a number, but an address.
What you should use is %p
. e.g.,
#include<stdio.h>
int main(void) {
int a;
a = 5;
printf("The memory address of a is: %p\n", (void*) &a);
return 0;
}
Good luck!