endian.c
changeset 106 a540a842ddef
parent 77 49e0babccb23
equal deleted inserted replaced
105:c19e37122deb 106:a540a842ddef
     9 int endian ()
     9 int endian ()
    10 {
    10 {
    11     unsigned short word = 0x1234;
    11     unsigned short word = 0x1234;
    12     unsigned char *p = (unsigned char *)&word;
    12     unsigned char *p = (unsigned char *)&word;
    13 
    13 
    14     return ((p[0] == 0x34) ? 0 : 1);
    14     return (p[0] == 0x34);
    15 }
    15 }
    16 
    16 
    17 int main (int argc, char **argv)
    17 int main (int argc, char **argv)
    18 {
    18 {
    19     printf ("%s Endian System\n", (endian ())? "Big" : "Little");
    19     printf ("%s Endian System\n", (endian ())? "Little" : "Big");
    20 
    20 
    21     return EXIT_SUCCESS;
    21     return EXIT_SUCCESS;
    22 }
    22 }