I wrote a program to find out whether my computer is big or little endian. Below is my code and its output in decimal are 87 d6 12 0. I know that big endian stores the most significant byte in the smallest address (that number will be printed first), and little endian stores the least significant byte in the smallest address (that byte will be printed first). My problem is determining which end of the output is the most significant bit and which is least significant bit. How do I determine that?
main.cc
main.cc
Code:
int main() {
int n = 1234567;
unsigned char* byte = (unsigned char*) (&n);
printf("%x %x %x %x\n", (int)byte[0],
(int)byte[1],
(int)byte[2],
(int)byte[3]);
} // end of main