endian

23 Sep

C program to check byteorder

in byteorder, c programming, endian

Here is an interesting snippit of code that can determine the byte order of your system - or - it's Endianness.

  1. #include <endian.h>
  2. #include <stdio.h>
  3.  
  4. int main (void) {
  5. #if BYTE_ORDER == LITTLE_ENDIAN
  6.  printf("system is little Endian \n");
  7. #elif BYTE_ORDER == BIG_ENDIAN
  8.  printf("system is big Endian \n");
  9. #else
  10.  printf("whats going on? \n");
  11. #endif
  12.  return 0;
  13. }

Pacific Simplicity 2010 All rights reserved. Contact