共用体案例一

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

union
{
    int n;
    double x;
}num;

int main()
{
    num.n  = 10;
    num.x  = 10.5;

    printf("num.n is %d\n",num.n);
    printf("num.x string   is %10f\n",num.x);

    return 0;
}

 

posted @ 2021-10-04 16:33  卷哭你  阅读(80)  评论(0编辑  收藏  举报