Created
January 8, 2019 06:35
-
-
Save saibikalpa/7e3e2201501cd5b88e1277d50f7ff191 to your computer and use it in GitHub Desktop.
Sample C program to determine 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
#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