top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

How to check machine type i.e. little endian or big endian ?

+1 vote
590 views
How to check machine type i.e. little endian or big endian ?
posted May 24, 2014 by Ganesh Kumar

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

Try with the following program which I found in some other question.

unsigned short num;
unsigned char * array;

num = 0xFF00;
array = (char *) num;
if(array[0] = 0x00)
{
   printf("littileEndian");
}
else
{
   printf("bigEndian");
} 

Read more at: http://tech.queryhome.com/12757/how-can-i-use-c-to-check-the-endianess-on-my-machine

answer May 24, 2014 by Salil Agrawal
just typo at
>if(array[0] = 0x00)
>if(array[0] == 0x00)
Thanks :) good catch
...