/ * Author: Chen Liang
Date: 2004-45-25
* /
(Note :) The following content is said under the 32-bit operating system.
C Common Data Type:
First, the first thing that must be cleared:
1. The basic unit of memory in the computer is Byte, which means that all data types in C are also based on byte.
2.1 byte = 8 bit (bit); 1kb (kilobyte) = 1024 byte.
3. The memory is aligned in a 4kb boundary. (1 page).
4. All things in your computer are stored in binary.
If you encounter any blame in the programming, try to consider it from the above perspective.
Second, the basic data type
CHAR occupies memory 1byte
INT occupies memory 4byte
Short occupies memory 2byte
Long occupation memory 4byte
Float occupies memory 4Byte
Double User Memory 8Byte
Third, pointer type
1. The pointer type can only be stored (I think this is the most important aspect of the pointer).
2. No matter what the pointer type occupies 4Byte's memory. (That is to say, it can point to the maximum memory 4G)
3. So any of the pointer types can be converted.
4. What role does the type of pointer type? Its role is only the type of content that this pointer points to the address. such as:
(1) INT * P; then P will add 4 (see INT). When using * P, it reads the continuous 4 bytes of the address
(2) Char * p; then P will add 1 (see two char). When using * P, it reads 1 byte of the address
(3) The transition like (int *) P is also only changed to INT to INT. This will add 4 when it is p
When using * P, it will read the continuous 4 bytes of the address.
Fourth, structural body
Struct mytest {
INT I;
Char C;
}
SIZEOF (STRUCT MyTest) = 8;
Why is this so? Because it is aligned with 4Byte (so speed will be much faster when the address of the CPU is taken).
So use the sizeof (Structure) to be particularly careful. To think about whether it is the result you want.