Dose anyone know what is meant by the term typecast in c programming? please explain!

Printable View

- 03-24-2004iBiZawhat is meant by the term typecast in c programming?
Dose anyone know what is meant by the term typecast in c programming? please explain!

- 03-24-2004Shadow
Maybe this should be in GD.

http://www.cprogramming.com/tutorial/lesson11.html

Search google also, this is a common programming topic. - 03-24-2004Thantos
Casting from one type to another.

For example you have a number that is of type float and you wanted to put it into a double

float x=1.24f;

double y = (double)x;

x is then promoted to a type of double.

I little more practical example.

int x = 5/2;

double y = 5/2;

double z = (double)5/2;

x = 2 since it is an integer

y you might think is 2.5 but its 2.0 since 5 and 2 are integers it goes with the rules of integer division first.

z however prompts 5 to a double then divides by 2 giving you the result of 2.5