int occupies two bytes in a 16-bit compiler, and int occupies four bytes in a 32-bit compiler. "int" is the type name of the integer type, and the type name of the long integer is "long int", which can be abbreviated as "long". "int" and "long" are both keywords.
int occupies two bytes in a 16-bit compiler, and int occupies four bytes in a 32-bit compiler.
1. 16-bit compiler
char: 1 byte char* (pointer variable): 2 bytes short int: 2 Byte int: 2 bytes unsigned int: 2 bytes float: 4 bytes double: 8 bytes long: 4 bytes long long: 8 bytes unsigned long: 4 bytes
2. 32-bit compiler
char: 1 byte char*: 4 bytes 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
Extended information:
The general classification of integer data is as follows:
1. Basic type: The type specifier is int, which occupies 2 bytes in memory.
2. Short integer type: The type specifier is short int or short. The occupied bytes and value range are the same as those of the basic type.
3. Long integer type: The type specifier is long int or long, which occupies 4 bytes in memory.
4. Unsigned type: The type specifier is unsigned. The unsigned type can be formed by matching the above three types:
1) Unsigned basic type: The type specifier is unsigned int or unsigned.
2) Unsigned short integer type: The type specifier is unsigned short.
3) Unsigned long integer: The type specifier is unsigned long.
Recommended tutorial: "C Language Tutorial"
The above is the detailed content of How many bytes does int occupy (c language)?. For more information, please follow other related articles on the PHP Chinese website!