1. Big Endian (The “Natural” Way)

  • MSB first & LSB last as we normally write

Memory Layout for 0x12345678:

AddressValue
0x10012
0x10134
0x10256
0x10378

2. Little Endian (The “Reverse” Way)

Little Endian stores the LSB first (at the lowest memory address). Most Intel/AMD processors (x86 architecture) use this.

Memory Layout for 0x12345678:

AddressValue
0x10078
0x10156
0x10234
0x10312

How to Check

We can inspect the first byte of an integer to see what lives there.

If you are on a Little Endian machine, the value of *c be ``

#include <stdio.h>

int main() {
    unsigned int x = 1;      // In hex: 0x00000001
    char *c = (char*) &x;    // Point a byte-pointer to the start of the integer

    printf("First byte value: %d\n", *c);
    return 0;
}