C program development, sometimes involves the concept of big and small end.
Let's take a look at the concept of small ends first. For example, there is a contiguous area of memory in memory, the address from 0x0 to 0x3; now there is an integer, with a 16 binary representation is 0x12345678, every two digits is a byte (16 concept everyone can be under Baidu), 0x12 is the highest byte, 0x78 is the lowest byte. Now save this integer in memory, as shown in the following illustration:
Memory address
|
0x0 |
0x1 |
0x2 |
0x3 |
Storage content |
0x12 |
0x34 |
0x56 |
0x78 |
The highest byte of the integer 0x12 is stored in the lowest address of the memory 0x0, the lowest byte of the integer 0x78 is stored in the highest address of memory 0x3, which is the big-endian.
If stored as follows:
Memory address
|
0x0 |
0x1 |
0x2 |
0x3 |
Storage content |
0x78 |
0x56 |
0x34 |
0x12 |
The highest byte of an integer 0x12 stored in the highest address of the memory 0x3, the lowest byte of the integer 0x78 stored in the lowest address of memory 0x0, which is the small end.
can also use the C program to determine whether the current system is big or small end, the specific C program please see the next article.