摘要: 笔者编码经验比较少,union只知概念,几乎没用过。昨日看到在UNP上一个示例程序如下判断系统使用大端还是小端1 #include "stdio.h" 2 int 3 main(int argc, char **argv) 4 { 5 union { 6 short s; 7 char c[sizeof(short)]; 8 } un; 9 un.s = 0x0102;10 printf("%s: ", CPU_VENDOR_OS);11 if (sizeof(short) == 2) {12 ... 阅读全文
posted @ 2012-04-13 09:41 五岳 阅读(307) 评论(0) 推荐(0) 编辑
回到顶部