Synleb Synleb - 1 year ago 73
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);

Answer Source

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!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download