Type conversion in C

From Wikipedia, the free encyclopedia
Jump to: navigation, search

In the C programming language, a type conversion is the conversion two different sorts of data type into a common form, in order for them to be manipulated.

In the C language there are different basic data types, such as int, char, float, double; there are also some user defined data types such as structures, arrays, etc. If the operator is taking operands of different data types, then they are converted to a common data types by certain rules. Generally, automatic conversions are those which can convert a narrower operand into a wider one without loss of information. For example, converting an integer to floating point in examples like float + integer (on 64-bit machine). A char is simply a small integer, so chars may be freely used in arithmetic expressions.