哪个变量零件都存放在这个code堆栈? [英] which variable parts are stored to the stack in this code?
本文介绍了哪个变量零件都存放在这个code堆栈?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个以下code和我真的不明白这部分变量在 test_function 被储存到堆栈段?
在这本书它说:这些变量的存储在堆栈段,所以我presume它是当变量实际上是初始化为一个值。对吧?
无效test_function(INT A,INT B,INT C,INT D){
INT标志; //是这个
炭缓冲液[10]; //这
//要么
标志= 31337; //这一点,
缓冲[0] ='A'; //这个。或全部呢?
}诠释主(){
test_function(1,2,3,4);
}
解决方案
标志
,缓存
和 A,b,C,D
将是在栈上(以及编译器可能只是删除所有code和调用它死code,因为它是未使用)。
I have this following code and I don't really understand which variable parts in the test_function are stored onto the stack segment?
In the book it says "The memory for these variables is in the stack segment", so I presume it is when the variables are actually initialized to a value. Right?
void test_function(int a, int b, int c, int d) {
int flag; //is it this
char buffer[10];// and this
//or
flag = 31337; //this and
buffer[0] = 'A'; //this. Or all of it?
}
int main() {
test_function(1, 2, 3, 4);
}
解决方案
flag
, buffer
, and a,b,c,d
will be on the stack (well compiler may just remove all the code and call it dead code since it's unused).
这篇关于哪个变量零件都存放在这个code堆栈?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文