Basic knowledge points of C language (8) Union and big and small endian modes

The output of the following program is ()

union myun {
    struct { int x, y, z;} u;
    int k;
} a;
int main()
{
    a.u.x = 4;
    a.u.y = 5;
    a.u.z = 6;
    a.k = 0;
    printf("%d\n", a.u.x);
}

little endian mode

The low bits of the data are placed in the low address space, and the high bits of the data are placed in the high address space
. Shorthand: little endian means that the low bits correspond to low addresses, and the high bits correspond to high addresses.

big endian mode

The high bits of the data are placed in the low address space, and the low bits of the data are placed in the high address space.

Store binary numbers: 1011-0100-1111-0110-1000-1100-0001-0101

Guess you like

Origin blog.csdn.net/qq_51519091/article/details/133150351