close
#include <stdio.h>


union udata {
    int x;
    long y;
    double z;
    char *a;
};

struct sdata {
    int x;
    long y;
    double z;
    char *a;
};

int main(void)
{
    printf("%d\n", sizeof(union udata));//union為共用memory,顯示:8
    printf("%d\n", sizeof(struct sdata));//struct為獨立memory,顯示:24
    
    return 0;
}

arrow
arrow
    全站熱搜

    天才R 發表在 痞客邦 留言(0) 人氣()