write a program to find whether the m/c is big endian or little endian

Big endian and little endian are two formats to store multibyte data types into computer's memory. These two formats are also called network byte order and host byte order respectively.

let's try to understand problem:



code:
#include <stdio.h> 
int main ()
{
unsigned int x = 0x76543210;
char *c = (char*) &x;
printf ("value of *c is: 0x%x\n", *c);
if (*c == 0x10)
printf ("your Machine architecture is little endian. \n");
else
printf ("your Machine architecture is Big Endian. \n");
return 0;
}

output:-
value of *c is: 0x10
your Machine architecture is little endian.

0 comments: