C- union

作者: 代瑶 | 来源:发表于2021-11-28 10:25 被阅读0次

union 公用体

union mytest
{
    int n;      
    char a ;  
    short t;
} test;

test.n = 0x3E25AD54; 

printf("test.n %-9X   test.a %-9X  test.t %-9X", test.n, test.a, test.t);

#输出结果是  test.n 3E25AD54   test.a 54   test.t FFFFAD54

double 占用8个字节
int 占用4个字节
short 占用2个字节
char 占用1个字节

相关文章

网友评论

      本文标题:C- union

      本文链接:https://www.haomeiwen.com/subject/ypmcxrtx.html