Dereference void pointer

c, pointers

Solution

`printf("\nlVptr[60 ] is %d \n", *(int*)lVptr);`

This will cast the void pointer to a pointer to an `int` and then dereference it correctly.

If you want to treat it as an array (of one), you could do a slightly ugly `((int *)lVptr)[0]`. Using `[1]` is out of bounds, and therefore not a good idea (as for `lVptr[60]`...)

Problem

Even after casting a void pointer, I am getting compilation error while dereferencing it. Could anyone please let me know the reason of this. ``` int lVNum = 2; void *lVptr; lVptr = (int*)&lVNum; printf("\nlVptr[60 ] is %d \n",lVptr[1]); ```

Original source