Hi Experts
I need some help in static memory allocation in C. I have a program in which I declared 2 variables, one char array and one integer. I was little surprised to see the addresses of the variables.
First:
int x;
char a[2];
printf("%u %u\n', &x, a);
I got the addresses displayed as : 3219437172 3219437170
The above result is straight forward wherein the array a got 2 bytes allocated.
Second:
When I changed the program as below:
int x;
char a[3];
printf("%u %u\n', &x, a);
I got the addresses displayed as : 3219437172 3219437144
The array a got allocated 28 bytes when the declaration is for 3 bytes.
Why so?