i have below code, doing type cast of integer pointer void pointer , try assign char address.
void main() { int *ptr; char = 10; (void *)ptr = &a; printf("%d\n", *ptr); }
i getting below error, there anyway can fix this?
error: lvalue required left operand of assignment (void *)ptr = &a;
yes, you cannot cast left operand of assignment operator in c.
also, in case other way make code work:
void main() { int *ptr; char = 10; ptr = (int*) &a; // fine printf("%d\n", *ptr); }
Comments
Post a Comment