c - What memory space is occupied by auto variables in stack -
i read functions in c may use local stack-based variables, , allocated decrementing stack pointer amount of space required. done in four-byte chunks (if not mistaken). but, if run code following:
void foo(void) { char str[6]; ...... }
what size var str
occupy? 6
bytes or 6 × 4
bytes per four-byte chunks.
the four-byte-chunk rule means stack pointer must point address multiple of four. in case, allocating 8 bytes satisfies rule, , such block large enough hold 6-character array 2 bytes of padding.
Comments
Post a Comment