home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / hacking / unix / crackunx.txt / Sources / bytesex.c next >
Encoding:
C/C++ Source or Header  |  1992-06-25  |  564 b   |  33 lines

  1. #include <stdio.h>
  2.  
  3. main ()
  4. {
  5.     char *p;
  6.     long int l;
  7.  
  8.     l = 'a' << 24 | 'b' << 16 | 'c' << 8 | 'd';
  9.     p = (char *) &l;
  10.  
  11.     if (sizeof (long int) == 4)
  12.     {
  13. #ifndef GCC            /* gcc tends to make a botch of it */
  14.     puts ("-DFDES_4BYTE");
  15. #endif
  16.     } else if (sizeof (long int) == 8)
  17.     {
  18.     puts ("-DFDES_8BYTE");
  19.     l <<= 32;
  20.     } else
  21.     {
  22.     printf ("-DFDES_%dBYTE%c", sizeof (long int), 10);
  23.     }
  24.     if (!strncmp (p, "abcd", 4))
  25.     {
  26.     puts ("-DBIG_ENDIAN");
  27.     } else if (!strncmp (p, "dcba", 4))
  28.     {
  29.     puts ("-DLITTLE_ENDIAN");
  30.     }
  31.     exit (0);
  32. }
  33.