Gcc error, invalid use of void expression

void *foo(void *a)
{
        a = (int *)a;
        (*a)PP;
        printf( "a = %d\n", *a);
}
The

program is like this, always saying that there are errors in the second and third lines!

C
Apr.05,2021

an is void*, and cannot be dereferenced. In addition, the sentence a = (int*) a; is meaningless. You change a to int* , then assign it to a, and then become void * La


.

C is a statically typed language. When you specify void * a , an is always void * within its valid domain. When you want to use int * , just use a new variable. For example:

void *foo(void *a)
{
        int *b = (int *)a;
        (*b)PP;
        printf("a = %d\n", *b);
}
Menu