我找到了一些像这样得到struct大小的代码:
sizeof(struct struct_type[1]);
我测试过它确实返回了它的大小struct_type.
和
sizeof(struct struct_type[2]);
返回结构大小的两倍.
编辑:
struct_type 是一个结构,而不是一个数组:
struct struct_type {
    int a;
    int b;
};
究竟struct_type[1]是什么意思?
Ser*_*gio 24
记住sizeof语法:
sizeof ( typename );
这里typename是struct struct_type[N]或者更可读的形式struct struct_type [N],它是struct struct_type类型的N个对象的数组.如您所知,数组大小是一个元素的大小乘以元素的总数.
sps*_*sps 13
就像:
sizeof(int[1]); // will return the size of 1 int
和
sizeof(int[2]); // will return the size of 2 ints
那样做:
sizeof(struct struct_type[1]); // return size of 1 `struct struct_type'
和
sizeof(struct struct_type[2]); // return size of 2 `struct struct_type'
这里struct struct_type[1],struct struct_type[2]简单地表示arrays类型的元素struct struct_type,并且sizeof只是返回那些表示的数组的大小.
为宣言
int arr[10];
数组的大小可以通过使用arr作为操作数来计算int [10].由于sizeof操作者产生基于操作数的类型的大小,都sizeof(arr)和sizeof (int [10])将返回数组的大小arr(最终arr是类型的int [10]).   
C11-§6.5.3.3/ 2:
sizeof运算符产生其操作数的大小(以字节为单位),该操作数可以是表达式或类型的带括号的名称.大小由操作数的类型确定.结果是整数.如果操作数的类型是可变长度数组类型,则计算操作数; 否则,不评估操作数,结果是整数常量.
同样,对于一个数组 struct struct_type  
struct struct_type a[1];
大小可以通过sizeof (a)或计算sizeof(struct struct_type[1]).