I'm trying to clear up a little bit of my beginner's confusion about how things are stored in memory.
Suppose I have the following code:
When I use gdb, I see that ptr1 contains an address ending in 07, and ptr2 contains an address ending in 1a. If I did my hex math correctly, that's 0x13 which is 19 bytes away. From this I gather that the stack is growing up. However, if buffer2 is sitting on top of buffer1 in the stack, and buffer2 is 10 bytes, shouldn't buffer2 be only 10 bytes away from the head of buffer1?Code:char buffer1[5]; char buffer2[10]; char *ptr1 = buffer1; char *ptr2 = buffer2;
Then I thought about memory only being word addressable, so really buffer1 takes up 8 bytes because that makes two words, and buffer3 takes up 3 bytes because that makes three words. Where does this "extra" storage get filled up? And even so, how can the blocks be 19 bytes away because that doesn't divide evenly into words.