/*
 * 反转四字节整型字节序
 */
unsigned int *ReverseWord(unsigned int *word)
{
    unsigned char *byte, temp;

    byte = (unsigned char *)word;
    temp = byte[0];
    byte[0] = byte[3];    
    byte[3] = temp;

    temp = byte[1];
    byte[1] = byte[2];
    byte[2] = temp;
    return word;
}

 

 

/*
 * 反转字节序
 */
void *ReverseByteOrder(void *p, unsigned int len)
{
    unsigned int i;
    unsigned char *bytes, temp;

    bytes = (unsigned char *)p;
    for (i = 0; i < len / 2; i++)
    {
        temp = bytes[i];
        bytes[i] = bytes[len - 1 - i];
        bytes[len - 1 - i] = temp;
    }
    return p;
}

 

 

相关文章:

  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-07
  • 2022-12-23
  • 2021-10-03
猜你喜欢
  • 2021-11-17
  • 2021-07-03
  • 2021-12-24
  • 2021-10-22
  • 2021-10-29
相关资源
相似解决方案