Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
26 views1 page

Host Byte Order

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 1

#include "unp.

h"
#include<stdlib.h>
int main(int argc, char **argv)
{
union {
short s;
char c[sizeof(short)];
}un;
un.s=0x0102;
//printf("%s \n", CPU_VENDOR_OS);
if(sizeof(short)==2)
{
if(un.c[0]==1 && un.c[1]==2)
printf("big endian\n");
else
if(un.c[0]==2 && un.c[1]==1)
printf("little endian\n");
else
printf("unknown\n");
}
else
printf("sizeof(short)=%d\n",sizeof(short));
exit(0);
}

You might also like