#include stdio.h
typedef union s{
int i;
char c[4];
} Utype;
int main()
{
Utype u;
char c;
u.i = 0x12345678;
printf(" %p - 0x%X\n", &u.i, u.i);
printf(" %p - 0x%X\n", &u.c[0], u.c[0]);
printf(" %p - 0x%X\n", &u.c[1], u.c[1]);
printf(" %p - 0x%X\n", &u.c[2], u.c[2]);
printf(" %p - 0x%X\n", &u.c[3], u.c[3]);
c = (u.i & 0x00000078);
if(c == u.c[0])
printf("\n***LITTLE ENDIEN***\n");
else
printf("\n***BIG ENDIEN***\n");
}
0 comments:
Post a Comment