Convert Little Endian to Big Endian

前端 未结 13 1834
慢半拍i
慢半拍i 2020-11-27 16:34

I just want to ask if my method is correct to convert from little endian to big endian, just to make sure if I understand the difference.

I have a number which is st

13条回答
  •  执笔经年
    2020-11-27 16:50

    one more suggestion :

    unsigned int a = 0xABCDEF23;
    a = ((a&(0x0000FFFF)) << 16) | ((a&(0xFFFF0000)) >> 16);
    a = ((a&(0x00FF00FF)) << 8) | ((a&(0xFF00FF00)) >>8);
    printf("%0x\n",a);
    

提交回复
热议问题