#include<stdio.h> struct student{ int num; char sex; float score; } ; union data{ int k; char ch; float f; }; int main(void){ printf("%d ",sizeof(struct student)); printf("%d",sizeof(union data)); }
详细计算见:https://blog.csdn.net/u012807459/article/details/48545141 博客,写的很好。规则要理解并且记下来。