首先分配基本变量(分配顺序字节从小到大char->int,除char按照singed->unsigned区分,其余均不),地址从低地址-高地址分配。
其次分配数组,地址从低地址-高地址。
一定要注意字节对齐:一般为4字节。
举例:
int ab[10];//最后
int m;
//⑤
char t;
//①
unsigned char ut;//②
unsigned short us;//③
short s;
//④
unsigned int n;//⑥
printf("=%p
%p %p %p%p
%p\n",&m, &n, &s, &t, &ut, &us);
for(m=0; m<10; m++)
printf("%p\n", &ab[m]);
打印:
=0xbfb05510 0xbfb05514 0xbfb0550e 0xbfb0550a 0xbfb0550b 0xbfb0550c
0xbfb05528
0xbfb0552c
0xbfb05530
0xbfb05534
0xbfb05538
0xbfb0553c
0xbfb05540
0xbfb05544
0xbfb05548
0xbfb0554c