top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

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

+1 vote
50 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 Google+ Share Button LinkedIn Share Button Multiple Social 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...