为什么在C中每次执行后变量的地址都会改变? [英] Why address of a variable change after each execution in C?
本文介绍了为什么在C中每次执行后变量的地址都会改变?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
int i=10;
printf("Address of i = %u",&i);
Output:
Address if i = 3220204848
Output on re-execution:
Address of i = 3216532594
每次执行程序时,都会得到一个新的地址i
.这意味着什么?
I get a new address of i
each time I execute the program. What does this signify?
推荐答案
它表示您每次运行程序时都在为其加载一个不同的(虚拟)地址.这是称为地址空间布局随机化(ASLR)的功能,并且是大多数现代操作系统的功能
It signifies that your program is being loaded a different (virtual) address each time you run it. This is a feature called Address Space Layout Randomization (ASLR) and is a feature of most modern operating systems.
这篇关于为什么在C中每次执行后变量的地址都会改变?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文