Tuesday, May 3, 2011

#C_CODE: Endian checker

#include <stdio.h>

int isLittleEndian(void)
{
    unsigned int i = 0x01;
    return (*((unsigned char *)&i));
}

int main(void)
{
    printf("Is the machine little endian: %s\n",
    isLittleEndian()?"YES":"NO");
}

No comments: