Big endian is where Most Significant Byte is handled first. Little endian is where Least Significant Byte is handled first.
To determine if a machine is Big endian or little endian, declare an integer (which has its MSB=0) and create a character pointer to the location and print the character value at the address. If the value is same as the
integer, it is Little endian otherwise it is Big endian.
#include <studio.h>
int main()
{
int i =1;
char * pc = (char *)&i;
if (*pc == 1)
printf(“Little endian.\n”);
else
printf(“Big endian.\n”);
}
Comments