Skip to content

Instantly share code, notes, and snippets.

@gauteh
Created January 9, 2013 15:03
Show Gist options
  • Save gauteh/4493784 to your computer and use it in GitHub Desktop.
Save gauteh/4493784 to your computer and use it in GitHub Desktop.
/* Based on: http://stackoverflow.com/questions/8571089/how-can-i-find-endian-ness-of-my-pc-programmatically-using-c
*
* Build: gcc -o whatendianness whatendianness.c
*
*/
# include <stdio.h>
int main (int argc, char **argv) {
int num = 1;
if (*(char *) &num == 1) {
printf ("Endianness: Little-endian\n");
return 0;
} else {
printf ("Endianness: Big-endian\n");
return 1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment