Created
January 18, 2015 11:18
-
-
Save ondrejsika/4963a14c14613bf84503 to your computer and use it in GitHub Desktop.
Check endianness
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcc -o endinanness endinanness.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void){ | |
int num = 1; | |
if(*(char *)&num == 1){ | |
printf("Little Endian\n"); | |
} | |
else { | |
printf("Big Endian\n"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment