Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Compile and Execute C Online

#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;
}

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.