+2 votes
in Computer Architecture by
Source code needed.

1 Answer

+1 vote
by
 
Best answer

Below is a source code for a small program that determines the endianness of a machine, with the results reported.

#include <stdio.h>

main()

{

int integer;

char *p;

integer = 0x30313233; /* ASCII for chars '0', '1', '2', '3' */

p = (char *)&integer

if (*p=='0' && *(p+1)=='1' && *(p+2)=='2' && *(p+3)=='3')

printf("This is a big endian machine.\n");

else if (*p=='3' && *(p+1)=='2' && *(p+2)=='1' && *(p+3)=='0')

printf("This is a little endian machine.\n");

else

printf("Error in logic to determine machine endian-ness.\n");

}

Related questions

Welcome to CPEN Talk
Solution-oriented students of computer engineering on one platform to get you that

ONE SOLUTION

Chuck Norris does infinit loops in 4 seconds.
...