c语言共用体的使用和long类型长度
#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\n",(char)frame_size); // 0x78
printf(" hello world c is %x\n",m.c); // 0x78
printf(" long size is %x\n",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\n",a.i); printf("union %x\n",a.video_data); return 0; }
一勤天下无难事。

浙公网安备 33010602011771号