Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - What is the significance of data type conversion in C language?
What is the significance of data type conversion in C language?
Indeed, for beginners, there is no need to force data type conversion most of the time. The main significance of learning type conversion is to make you understand this concept, because although you haven't written it, in fact, automatic type conversion happens almost all the time.

For example, if the expression 5/0.5 is written, 5 is recognized as an integer and 0.5 is recognized as a floating-point type. There is no operation between these two types, so automatic type conversion will occur, and the integer will be upgraded to floating-point type before continuing the operation.

Learning the concept and usage of type conversion is very helpful for you to write programs to troubleshoot problems. Data type conversion will appear more frequently in future knowledge. For example, you will encounter the malloc function, which returns any type of pointer void*, and you need to cast it to use it:

int * p =(int *)malloc(sizeof(int));