#1 Download computer science & engineering books free           #2 Display your sponsored posts here. Reach 20,000+ students. Contact: info[at]cpentalk.com for quote           #3 Take the Ultimate Trivia Quiz. See where you rank globally.
+2 votes
in Computer Architecture by
Source code needed.

1 Answer

+1 vote
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>



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");


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


Every SQL statement that Chuck Norris codes has an implicit "COMMIT" in its end.