Why address of a variable change after each execution in C?

后端 未结 4 1866
既然无缘
既然无缘 2021-01-19 01:03
int i=10;
printf(\"Address of i = %u\",&i);

Output:
Address if i = 3220204848

Output on re-execution:
Address of i = 3216532594

I get a new a

4条回答
  •  悲&欢浪女
    2021-01-19 01:23

    Disable ASLR using:

    echo 0 | sudo tee /proc/sys/kernel/randomize_va_space
    

    You will always see the same address.

提交回复
热议问题