Stack grows from high memory to low memory. Knowing that i declared 3 variables and was expecting that the first declared would have the biggest address, and the last one the lowest. It didn't turn out that way. Why is this?
Code:
#include <stdio.h>
#include <string.h>
#define BUFFSIZE 8
int main(int argc, char** argv)
{
int val = 7;
char buff1[BUFFSIZE];
char buff2[BUFFSIZE];
printf("val is at %p\n", &val);
printf("buff1 is at %p\n", buff1);
printf("buff2 is at %p\n", buff2);
return 0;
}
Code:
OUTPUT:
val is at 0x7ffcae0c5bbc
buff1 is at 0x7ffcae0c5bc0
buff2 is at 0x7ffcae0c5bd0