#include <stdio.h>

typedef union{
    unsigned short value;
    unsigned char byte[2];
}CodeOrderUnion;

void test_endian()
{
    CodeOrderUnion order;
    order.value = 0x0102;
    if(order.byte[0] == 0x01 && order.byte[1] == 0x02){
        printf("Small Endian\n");
    }
    else if(order.byte[0] == 0x02 && order.byte[1] == 0x01){
        printf("Big Endian\n");
    }
    else{
        printf("error!\n");
    }
}

int main()
{
    test_endian();
}

 

相关文章:

  • 2021-12-30
  • 2021-04-02
  • 2021-06-10
  • 2022-12-23
  • 2022-12-23
  • 2022-02-06
  • 2021-12-29
猜你喜欢
  • 2022-12-23
  • 2021-05-29
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2022-01-01
  • 2022-12-23
相关资源
相似解决方案