UNIX网络编程第3章套接字编程简介3.2套接字地址结构3.3值结果参数3.4字节排序函数
时间:2015-03-15 13:40:10
收藏:0
阅读:210
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:
评论(0)

![][E(AUVLO}M8G}HQ}28ESFJ 技术分享](http://image.mamicode.com/info/201503/20180925121456951754.png)
![YQ1HNDSQ]E@P3_}PS)QRI2Y 技术分享](http://image.mamicode.com/info/201503/20180925121457259351.png)
![`%]F7$7FR1CCNY_WA`CE@Y2 技术分享](http://image.mamicode.com/info/201503/20180925121457577690.png)





![EYS]TW`FXX9`41UL}JG1VME 技术分享](http://image.mamicode.com/info/201503/20180925121459939844.png)





![JS}N}Q3FVKR58NJTN]O@O@V 技术分享](http://image.mamicode.com/info/201503/20180925121503414231.png)






































