#include
#define BIG_ENDIAN 0
#define LITTLE_ENDIAN 1
int TestByteOrder(void);
int TestByteOrder(void)
{
short int word = 0x0001;
char *byte = (char *) &word;
return (byte[0] ? LITTLE_ENDIAN : BIG_ENDIAN);
}
int main(void)
{
printf("The Endianness of the platform is: %s\n", TestByteOrder() ? "LITTLE Endian" : "BIG Endian");
return 0;
}
No comments:
Post a Comment