定义如下一个struct
struct
T
{
int a;
int b[ 0 ];
int c;
};
打印各个成员的地址和大小,结果如下:
{
int a;
int b[ 0 ];
int c;
};
编译环境Code::Blocks 10.05
struct
T t;
printf( " %p:%d/n " , & (t.a), sizeof (t.a));
printf( " %p:%d/n " , & (t.b), sizeof (t.b));
printf( " %p:%d/n " , & (t.c), sizeof (t.c));
printf( " %p:%d/n " , & (t.a), sizeof (t.a));
printf( " %p:%d/n " , & (t.b), sizeof (t.b));
printf( " %p:%d/n " , & (t.c), sizeof (t.c));
0022FF38:
4
0022FF3C: 0
0022FF3C: 4
可见定义的空数组,是不占任何空间的。其返回的内存地址是下一个可分配的地址
0022FF3C: 0
0022FF3C: 4