home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / sml_nj / 93src.lha / src / runtime / endian.c < prev    next >
Encoding:
Text File  |  1993-02-09  |  305 b   |  21 lines

  1. /* endian.c
  2.  *
  3.  * COPYRIGHT (c) 1990 AT&T Bell Laboratories.
  4.  *
  5.  * Determine the endianess of this machine.
  6.  */
  7.  
  8. char        s[4] = {0x01, 0x02, 0x04, 0x08};
  9.  
  10. main ()
  11. {
  12.     int        *p = (int *)s;
  13.  
  14.     if (*p == 0x01020408)
  15.     printf("Big\n");
  16.     else if (*p == 0x08040201)
  17.     printf("Little\n");
  18.     else
  19.     exit(1);
  20. }
  21.