void main()
{
void *v;
int integer=2;
int *i=&integer;
v=i;
printf("%d",(int*)*v);
}
this simple program will result in a compiler error saying:
Compiler Error. We cannot apply indirection on type void*
what exact does this error mean?
void main()
{
void *v;
int integer=2;
int *i=&integer;
v=i;
printf("%d",(int*)*v);
}
this simple program will result in a compiler error saying:
Compiler Error. We cannot apply indirection on type void*
what exact does this error mean?
You cannot dereference pointers to void (i.e., void *). They point to a memory location holding unknown data so the compiler doesn't know how to access/modify that memory.
The error means exactly what it says. The error is triggered by the *v subexpression used in your code.
Unary operator * in C is often called indirection operator or dereference operator. In this case the compiler is telling you that it is illegal to apply unary * to a pointer of type void *.