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;
}
}
浙公网安备 33010602011771号