网络编程day1


#include 
 
typedef union{
	unsigned short int value;
	unsigned char bytes[2];
}Bytes;
 
 
int main(int argc, const char *argv[])
{
	unsigned short int val = 0x0201;
	Bytes b;
	b.value = val;
	if(b.bytes[0] == 0x01 && b.bytes[1] == 0x02){
		printf("小端字节序\n");
	}else if(b.bytes[0] == 0x02 && b.bytes[1] == 0x01){
		printf("大端字节序\n");
	}else{
        printf("未知字节序\n");
    }
	return 0;

你可能感兴趣的:(算法,linux,运维)