Advertisement
ringneckparrot

EndiannessTest Undocumented

Apr 9th, 2012
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.78 KB | None | 0 0
  1. /****************************************************************************
  2.     ringneckparrot (c)
  3.     License: http://creativecommons.org/licenses/by-nc-sa/3.0/
  4.    
  5.     Contact Me:
  6.     Email: ringneckparrot@hotmail.com
  7.     Facebook: http://www.facebook.com/ringneckparrot
  8.     Twitter ID: pp4rr0t
  9.     SecurityTube: http://www.securitytube.net/user/ringneckparrot
  10.  
  11. ****************************************************************************/
  12.  
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15.  
  16. #define LITTLE 0
  17. #define BIG 1
  18.  
  19. int EndiannessTest()
  20. {
  21.     int i = 1;
  22.     char *p = (char *) &i;
  23.  
  24.     if(*p == 1)
  25.         return LITTLE;
  26.     else
  27.         return BIG;
  28.    
  29. }
  30.  
  31. int main()
  32. {
  33.     int Endian;
  34.     Endian = EndiannessTest();
  35.  
  36.     if (Endian == LITTLE)
  37.         printf("Little Endian\n");
  38.     if (Endian == BIG)
  39.         printf("Big Endian\n");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement