Casting to long long (GCC)
long long x; double n;
x=long long(n);
This doesn't work. What is the corre开发者_开发技巧ct way?
The obvious:
x = (long long) n;
C does not have constructors, this looks like a C++ constructor call.
In C, the syntax of a cast is a type name in parenthesis. It works as a prefix operator, changing the type of the expression to the right:
long long x = (long long) 3.14;
In any plain C / C++ compiler, in order to cast you have to use parentheses "(mytype)myvar", maybe you where confused because you required 2 separate words...
精彩评论