How to 共用体

#include <stdio.h>
int main()
{
 union Exam{
  struct {
   int x;
   int y;
  }in;
  int a;
  int b;
 }e;
 e.a=1;e.b=2;
 e.in.x=e.a*e.b;
 e.in.y=e.a+e.b;
 printf("%d,%d\n",e.in.x,e.in.y);
 return 0;
}

 

posted @ 2011-11-06 20:27  谈笑风生膜法师  阅读(133)  评论(0编辑  收藏  举报