C实现字节反转(任意长度的大小端转换)

函数声明如下:

void ZiJieXuFanZhuan(char * msg, size_t byteLength);

实现如下:

void ZiJieXuFanZhuan(char *msg, size_t byteLength)
{
    uint8_t tmp=0;

    for(int i=0; i<byteLength/2; i++){
        tmp = msg[i];
        msg[i] = msg[byteLength-i-1];

        msg[byteLength-1-i] = tmp;
    }

}

 

posted on 2025-02-05 14:15  明太宗朱棣  阅读(21)  评论(0)    收藏  举报

导航