When is stack space allocated for local variables?

前端 未结 5 2111
独厮守ぢ
独厮守ぢ 2021-01-02 02:54

I have a question about the following C code:

void my_function()
{
    int i1;
    int j1;

    // Do something...

    if (check_something())
    {
                 


        
5条回答
  •  盖世英雄少女心
    2021-01-02 03:33

    If the variables are going to be put on the stack, the stack space is allocated at the beginning of the function before the first statement in the function. The stack pointer will be moved up (or down) the total number of bytes to store all the local variables.

提交回复
热议问题