byte数组,按byte按位倒叙排列算法

void TransformBuffer(char* buffer, const int size)
{
int i,j;
char des = 0;
char tmp = 0;
char src = 0;

for (int i = 0; i < size; i++)
{
    src = buffer[i];
    des = 0;
    tmp = 0;

    for (j = 0; j < 8; j++)
    {

        if (src & 0x1)
            buffer[i] |= 1 << (7 - j);
        else
            buffer[i] &= ~(1 << (7 - j));
        src >>= 1;
    }       
}

}

你可能感兴趣的:(C/C++)