I. program running platformThe number of bytes allocated for different data types varies on different platforms. My personal understanding of the platform is CPU + OS + compiler, because: 1. 64-bit machines can also be installed with 32-bit systems (Windows XP x64 ); 2. A 32-bit machine can have a 16/32-bit Compiler (on XP, TC is 16-bit, and other common ones are 32-bit ); 3. Even a 32-bit compiler can generate 64-bit integers (int64 ). These are based on the common Wintel platform, and other platforms (other CPU and OS) that we may rarely have access to. Therefore, I personally think that the concept of the platform is a combination of the three. Although the length of the three can be different, it is clear that they work together (that is, the length is equal, 32-bit CPU + 32-bit OS + 32-bit compiler) to maximize the energy. Theoretically, I think the number of bytes of the data type should be determined by the CPU, but it is mainly determined by the compiler (the number of bytes is determined by the compiler during compilation ).
2. number of bytes corresponding to Common Data TypesIt can be obtained by sizeof (char) or sizeof (char *).
32-bit Compiler:
CHAR: 1 byte
Char * (pointer variable): 4 bytes (32-bit addressing space is 2 ^ 32, that is, 32 bits, that is, 4 bytes. Similarly, 64-bit compiler)
Short INT: 2 bytes
INT: 4 bytes
Unsigned INT: 4 bytes
Float: 4 bytes
Double: 8 bytes
Long: 4 bytes
Long long: 8 bytes
Unsigned long: 4 bytes
64-bit Compiler:
CHAR: 1 byte
Char * (pointer variable): 8 bytes
Short INT: 2 bytes
INT: 4 bytes
Unsigned INT: 4 bytes
Float: 4 bytes
Double: 8 bytes
Long: 8 bytes
Long long: 8 bytes
Unsigned long: 8 bytes
[To] the number of bytes corresponding to the Data Type