字节间反转和字节内反转

来源:互联网 发布:tc c语言现在版本 编辑:程序博客网 时间:2024/06/05 04:08

typedef unsigned char       U8;

//字节间反转

void Reverse_BYTE(U8 *p,int bytelen){int  i;U8  temp;for(i = 0; i <(bytelen/2); i++){temp = p[i];p[i] = p[bytelen -1 - i];p[bytelen -1 - i] = temp;}}
//字节内反转

U8 reverse8(U8 c){c = (c & 0x55) << 1 | (c & 0xAA) >> 1;c = (c & 0x33) << 2 | (c & 0xCC) >> 2;c = (c & 0x0F) << 4 | (c & 0xF0) >> 4;return c;}



0 0