I wonder how memory is allocated in c. In the example below, it looks like the compiler allocates some memory for the program and then goes backward. How and why does it work like that?
Code:
int main (void) {
int a;
int b;
int c, d;
printf("a: %p\nb: %p\nc: %p\nd: %p\n", &a, &b, &c, &d);
}
Output:
a: 0x7ffff275351c
b: 0x7ffff2753518
c: 0x7ffff2753514
d: 0x7ffff2753510