Reputation: 51
I need to write a small C program to demonstrate that the UNIX operating system is using Big Endian, and the MS-Windows/DOS system is using Little Endian. I'm having trouble putting my thoughts into code (beginner coder) but I'm assuming I can load a 32 bit word into an address and just check where the LSB is, but then again I'm still a beginner.
Can anyone help me out?
Upvotes: 0
Views: 658
Reputation: 33139
#include <stdio.h>
int main()
{
unsigned int i = 1;
char *c = (char*)&i;
if (*c) {
printf("Little endian");
} else {
printf("Big endian");
}
getchar();
return 0;
}
Upvotes: 4