Skip to content

Instantly share code, notes, and snippets.

@saibikalpa
Created January 8, 2019 06:35
Show Gist options
  • Save saibikalpa/7e3e2201501cd5b88e1277d50f7ff191 to your computer and use it in GitHub Desktop.
Save saibikalpa/7e3e2201501cd5b88e1277d50f7ff191 to your computer and use it in GitHub Desktop.
Sample C program to determine endianness
#include <stdio.h>
union s{
int n;
char b;
}x;
void main(){
x.n = 0x4142;
if(x.b == 0x42){
printf("Little Endian\n");
}
else{
printf("Big Endian\n");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment