반응형

#include <stdio.h>

#define BIG_ENDIAN    0
#define LITTLE_ENDIAN 1

int endian(void);

int main()
{

    if( endian() == LITTLE_ENDIAN ) {
        printf("Little Endian\n");
    }
    else {
        printf("Big Endian\n");
    }

}


int endian(void)
{
    int i = 0x00000001;

    if( ((char *)&i)[0] ) {

         return LITTLE_ENDIAN;

    }
    else {

         return BIG_ENDIAN;

    }

}

 

반응형
Posted by 공간사랑
,