I wrote following sample piece of code, just to print the address of a local variable.
Since the variable a
is in a known stack frame, so I thought its address is fixed.
But when I run the compiled binary multiple times, it print out different addresses.
I wonder why the address of a
keeps changing.
#include <stdio.h>
int main() {
int a = 1;
printf("address: %p\n", &a);
return 0;
}