Big endian or Little endian

How will you find whether your system is following Big endian or Little endian representations. Write C code. In Little endian, the lowest byte is stored in lowest address.

Showing Answers 1 - 3 of 3 Answers

saikamal

  • Jan 31st, 2016
 

The best way to check whether CPU follows little endian or big endian :
main()
{
int var=1;
char*p=&var;
if(*p==1)
printf("Little endian
");
else
printf("Big endian
");
}
NOTE:
size of all pointers are same but the main difference comes when you fetch the data back using specified data types.Here char*p holding the address of integer variable.so if cpu follows little endian then 1 will be present in lower address as char * will fetch only 1 byte.Simple...!!!

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions