Endianness is the order or sequence of bytes of a word data. Endianness is of two types
- Big-Endian (BE) – stores the most significant byte of a word at the smallest memory address and the least significant byte at the largest
- Little-Endian (LE) – stores the least-significant byte at the smallest address
$ vim check_endian.c
#include <stdio.h>
int main(int argc, char **argv) {
int num = 1;
if(*(char *)&num == 1) {
printf("\nLittle-Endian\n");
} else {
printf("Big-Endian\n");
}
}
$ gcc -o check_endian check_endian.c
$ ./check_endian