Pointer Arithmetic and Typecasting
Hi... Ok, there's no real purpose to this, I'm just bored... Anyway, basically I want to be able to manipulate a void pointer by assigning it the address of an integer, and try and manipulate the value of that integer via dereferencing and typecasting the void pointer and assigning it a value.
I'm trying to do it like so:
My take on the above is:
int y = 0;
void * x = &y;
(int *)(*x) = 5;
declare a void pointer and give it the address of the 'y' integer.
derference the pointer and typecast to a pointer to an integer.
I get the following compile errors:
Could someone please explain to me what I'm doing wrong, how I can accomplish this, why, and how, etc.
error C2100: illegal indirection
warning C4047: '=' : 'int *' differs in levels of indirection from 'int'
Trying to get a better understanding of the above.