Macro to swap nibble of BYTE source code

This snippet submitted by T Sailesh on 2006-06-08. It has been viewed 7111 times.
Rating of 6.3 with 13 votes

#define _swapNibble(x) ((x<<4)|(x>>4))

int main()
    // On executing you will get
    // x before swap = 0x1c
    // x after swap = 0xc1
    char x = 0x1c;
    printf("x before swap = %x\n",x);

    printf("x afer swap = %x",x);

More C and C++ source code snippets

Add a snippet!