#include <stdio.h> #define GET_BYTE(_N, _B) ((_N) >> ((_B) << 3)) #define XORSWAP(a, b) ((&(a) == &(b)) ? (a) : ((a)^=(b),(b)^=(a),(a)^=(b))) int main() { int x = 12345678; int k; for(k = 0; k < sizeof(x); k+=2) { XORSWAP(((char *)&x)[k], ((char *)&x)[k+1]); } printf("swapped: %lx", x); return 0; }
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more