Current post is on how to check whether computer is Big Endian or Little Endian.
Endianness refers - the order in which computer stores the bytes.
Little Endian - Stores LSB (Least Significant Byte) in lowest address.
Big Endian - Stores MSB (Most Significant Byte) in highest address.
Answer:
/* Function returns whether the computer system is Little or Big Endian*/bool IsLittleEndian()
{
int TestNumber = 1;
char * ptr;
ptr = (char *) &TestNumber;
return (*ptr); //True if little Endian.
}
Appreciate your feedback via comments. Thanks.