Noob alert;
I'm learning C and came across void*
What I don't understand is that, if I'm referencing an int variable with a void pointer, why can't I simply dereference ALSO with a void pointer. And if I want to, I have to typecast.
so why would I ever want to use void* to begin with If I'm always going to typecast it with, let's say an Integer. And why not just use int* all the time
Code:
int main()
{
int i = 10;
void* p = &i;
printf("%i", *(int*)p); // typecasting before dereferencing
return 0;
}