#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 */
{
} else {
}
}
I2luY2x1ZGUgPHN0ZGlvLmg+Cgp1bmlvbnsKY2hhciBhcnJbNF07CmxvbmcgZGF0YTsKfSB0ZXN0OwoKaW50IG1haW4oKSB7CmNoYXIgYyA9ICdhJzsKCi8qIFRlc3QgcGxhdGZvcm0gRW5kaWFubmVzcyAqLwpmb3IoaW50IHggPSAwOyB4IDwgNDsgeCsrKQp0ZXN0LmFyclt4XSA9IGMrKzsKaWYgKCB0ZXN0LmRhdGEgPT0gMHg2MTYyNjM2NCApCi8qIEl04oCZcyBiaWcgZW5kaWFuIGFuZCB5b3UgZG8geW91ciBzdHVmZiAqLwp7CnByaW50ZigiQmlnIGVuZGlhbiIpOwp9IGVsc2UgewpwcmludGYoIkxpdHRsZSBlbmRpYW4iKTsKfQp9