int a = 100;
Unsigned char * c = (unsigned char *) a;
2. Forced type conversion
When the types of operands are different and do not belong to the basic data types, it is often necessary to force type conversion to convert the operands into the required types. There are two forms of modeling, called explicit modeling and implicit modeling.
Explicitly forced type conversion
Explicit casts require a cast operator of the following format:
Type (< expression & gt)
or
(Type)< Expression & gt
Where type is a type descriptor, such as int, float, etc. & lt expression & gt is an expression. A numeric value of type is returned after a cast operator operation is forced. This forced type conversion operation will not change the operand itself, and the operand itself will not change after the operation. For example:
int nVar = 0x ab 65;
char cChar = char(nVar);
The result of the above forced type conversion is to delete the upper two bytes of the integer value 0xab65 and assign the lower two bytes to the variable cChar as the Char type value, but the value of nVar has not changed after the type conversion.