定义结构体类型“struct s{int x;float f;}a[3];”,则执行语句

定义结构体类型“struct s{int x;float f;}a[3];”,则执行语句“printf(“%d”,sizeof(a));”的输出结果是 24 为什么呀

struct s{ int x, float f;} a[3];
int,4字节,float ,4字节
所以,结构体,4+4=8字节
a[3], 有3个结构体,3x8=24字节
温馨提示:答案为网友推荐,仅供参考
第1个回答  2022-06-02
struct Stu{
int score[50];
float average;
}s;