Let’s say I have a pointer to a whole
int* iPtr;
Whereas it already points to a valid memory address, if I want to change the value of it I first need to override the pointer
*iPtr = 100; //atribuo o valor 100
So this * is what indicates that I am slipping this pointer and assigning the value to the memory to which it points, if I did not have the * there I would be trying to change the address to which this pointer points
But this works because the compiler knows the type, when using void* you own a generic pointer, as if you don’t have a defined type you can’t simply override this pointer, so you first need to cast it for another type of pointer so you can override it, whereas we have a variable void* voidPtr, in the example
*(int*)voidPtr = 100;
First the (int*) does the cast of void* for int*, then the first * melts the pointer to assign the value
Now it all makes sense! Thanks.
– pmargreff