Implicit conversion of data types occurs in the following four cases in the C operation:
1. In the arithmetic formula, the low type can be converted to the high type.
2. In the value assignment expression, the value of the right expression is automatically implicitly converted to the type of the Left variable and assigned to him.
3. When a parameter is passed in a function call, the system implicitly converts the real parameter to the type of the form parameter and assigns it to the form parameter.
4. When a function has a return value, the system implicitly converts the return expression type to the return value type and assigns the value to the called function.
Conversion rules:
When different types of data are operated, convert them to the same data type and then perform the operation. The conversion rule is from low-level to advanced conversion.
Shows the conversion rules:
Example:
# Include <stdio. h> # include <stdlib. h> int main () {unsigned int A = 6; int B =-20; (a + B> 6 )? Puts ("result is \ '> 6 \'"): puts ("result is \ '<= 6 \'"); Return 0 ;}
The output result is "the result is '> 6 '";
During the operation, B of the int type is first converted into an unsigned int, which will become a very large number. Therefore, A + B will become a very large number of unsigned int types, therefore, the output result is"The result is '> 6 '"
For more information, see
Http://blog.csdn.net/miaouu/article/details/5213042