结构体所占字节大小计算以及共用体大小计算

#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));
}

    

    详细计算见:https://blog.csdn.net/u012807459/article/details/48545141  博客,写的很好。规则要理解并且记下来。

     

猜你喜欢

转载自www.cnblogs.com/sunnybowen/p/8964182.html