共用体成员的引用

来源:互联网 发布:自制短片软件 编辑:程序博客网 时间:2024/04/29 13:02

#include "stdafx.h" #include"stdio.h" union pw {   int i;   char ch[2]; }a; int main(int argc, char* argv[]) {  a.ch[0]=13;  a.ch[1]=0;  printf("%d/n",a.i);

return 0; } 运行结果:13

(结构体所占内存中最后存放的数据是字符数组,结构体内各成员地址是一样的。而数组的地址就是它的首地址。)

原创粉丝点击