Calculation of the size of bytes occupied by the structure and calculation of the size of the union

#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.

     

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324980943&siteId=291194637