#include <stdio.h>
 
union{
    char arr[4];
    long data;
} test;
 
int main() {
    char c = 'a';
     
    /* Test platform Endianness */
    for(int x = 0; x < 4; x++)
    test.arr[x] = c++;
    if ( test.data == 0x61626364 )
    /* It’s big endian and you do your stuff */
    {
    printf("Big endian");
    } else {
    printf("Little endian");
    }
}