Synleb Synleb - 3 months ago 23
C Question

What is the difference between int and (int) in C?

For example: when I round a float into an int, why should I use :

int i = (int) round(f);

Instead of :

int i = int round(f);


Well by convention, doing (int) on a float is typecasting the float to an int. I'm not quite sure why you'd do int _ = int _ , although it may work just as well. By convention though, many languages (there are exceptions) in which you typecast go by the syntax of

... = (_type_) yourdatavalue

Hope that helps!