If I have for example
typedef struct node
{
int numbers[5];
} node;
Whenever I create an instance of such a struct there's gonna be allocation of memory in the stack for the array itself, (in our case 20 bytes for 5 ints(considering ints as 32 bits)), and numbers is gonna be a pointer to the first byte of that buffer. So, I thought that since inside an instance of node, there's gonna be a 20 bytes buffer(for the 5 int
s) and a 4 bytes pointer(numbers
), sizeof(node)
should be 24 bytes. But when I actually print it out is says 20 bytes.
Why is this happening? Why is the pointer to the array not taken into account?
I shall be very grateful for any response.