#include<stdio.h> struct student{ int num; char sex; float score; } ; union data{ int k; char ch; float f; }; int main(void){ printf("%d\n",sizeof(struct student)); printf("%d",sizeof(union data)); }
For detailed calculations, see: https://blog.csdn.net/u012807459/article/details/48545141 blog, well written. The rules are to be understood and written down.