#include <stdio.h> #include <stdlib.h> int main() { long frame_size = 0x12345678; union { int a; long b; char c; }m; m.b = 0x12345678; printf("Hello world! frame_size is %x ",(char)frame_size); // 0x78 printf(" hello world c is %x ",m.c); // 0x78 printf(" long size is %x ",sizeof(long)); // return 0; }
#include <stdio.h> #include <stdlib.h> union data { int i; char c; float f; long video_data; }a; int n; int main() { a.video_data = 0x123456789; printf("union %x ",a.i); printf("union %x ",a.video_data); return 0; }