标签:
1: #include <iostream>
2: #include "../lib/unpsunyj.h"
3:
4: int main(int argc, char **argv)
5: {
6: union {
7: short s;
8: char c[sizeof(short)];
9: } un;
10:
11: un.s = 0x0103;
12: std::cout << "un.s =: " << un.s << std::endl;
13: printf("%s: ", CPU_VENDOR_OS);
14: if (sizeof(short) == 2)
15: {
16: if (un.c[0] == 1 && un.c[1] == 3)
17: printf("big-endian\n");
18: else if (un.c[0] == 3 && un.c[1] == 1)
19: printf("little-endian\n");
20: else
21: printf("unknown\n");
22: }
23: else
24: printf("sizeof(short) = %d\n", static_cast<int>(sizeof(short)));
25:
26: return 0;
27: }
28:
UNIX网络编程第3章套接字编程简介3.2套接字地址结构3.3值结果参数3.4字节排序函数
标签:
原文地址:http://www.cnblogs.com/sunyongjie1984/p/4339449.html