1. Define several variables to store the number of bytes of each data type.
# Include <stdio. h>
Unsigned char a, B, c, d, e, f, g;
Main ()
{
A = sizeof (char );
B = sizeof (short INT );
C = sizeof (INT );
D = sizeof (long );
E = sizeof (long INT );
F = sizeof (float );
G = sizeof (double );
While (1 );
}
2. view the storage address of each variable. View --- symbols window.
3. view the stored values of each address. View --- Memory window.
Char occupies 1 byte
Short int occupies 2 bytes
Int occupies 4 bytes
Long occupies 4 bytes
Long int occupies 4 bytes
Float occupies 4 bytes
Double occupies 8 bytes
We can define the macro as follows:
typedef unsigned char uint8; // unsigned 8-bit integer variable
typedef signed Char int8; // signed 8-bit integer variable
typedef unsigned short uint16; // unsigned 16-bit integer variable
typedef signed short int16; // signed 16-bit integer variable
typedef unsigned int uint32; // unsigned 32-bit integer variable
typedef signed int int32; // signed 32-bit integer variable
typedef float fp32; // Single-precision floating point number (32-bit length)
typedef double fp64; // double-precision floating point number (64-bit length)