Pelles C forum
C language => Beginner questions => Topic started by: alexei on September 04, 2010, 11:29:49 AM
-
Other compilers are OK with this (see code below). Is it because of ANSI?
Is there a way to do such things without re-declaring variables?
I mean typecasting any variable to any type.
int main (int argc, char *argv[])
{
unsigned z;
void* p;
(int)z = (int)z-5;
(int)p = (int)p+2;
return 0;
}
Test.c(5): error #2088: Lvalue required.
Test.c(6): error #2088: Lvalue required.
-
Other compilers are OK with this (see code below). Is it because of ANSI?
Is there a way to do such things without re-declaring variables?
I mean typecasting any variable to any type.
Test.c(5): error #2088: Lvalue required.
Test.c(6): error #2088: Lvalue required.
The answer is no. You can sometimes cast the right side so that it matches the left side but you can never cast the left side or change a variable into a different type.
float f = 1.0;
int i;
i = (int)f;
John
-
Just curious wich compiler do you mean ?