随笔 - 505  文章 - 1034  trackbacks - 0
<2007年7月>
24252627282930
1234567
891011121314
15161718192021
22232425262728
2930311234


子曾经曰过:编程无他,唯手熟尔!

常用链接

留言簿(94)

随笔分类(649)

随笔档案(505)

相册

BCB

Crytek

  • crymod
  • Crytek's Offical Modding Portal

Game Industry

OGRE

other

Programmers

Qt

WOW Stuff

搜索

  •  

积分与排名

  • 积分 - 894656
  • 排名 - 14

最新随笔

最新评论

阅读排行榜

评论排行榜

 注意是从低位到高位


struct stTest
{
    union
    {
        
struct 
        {
            unsigned 
char byOne;
            unsigned 
char byTwo;
        };
        unsigned 
int feature;
    };
};

int _tmain(int argc, _TCHAR* argv[])
{
    stTest test;
    test.feature 
= 1;
    printf(
"%d %d\n", test.byOne, test.byTwo); // 1 0
    return 0;
}
posted on 2007-07-09 21:17 七星重剑 阅读(2962) 评论(2)  编辑 收藏 引用 所属分类: PL--c/c++

FeedBack:
# re: union 用法,汗!写了这么多年程序了,才用到 2007-07-10 21:36 Corner Zhang
呵呵,可以用来判断little endian or big endian  回复  更多评论
  
# re: union 用法,汗!写了这么多年程序了,才用到 2008-07-17 17:10 过客
同意楼主  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理