I was practicing with void pointers when this code successfully compiled:
#include <stdio.h>
int main()
{
void *x = (void*) 576;
int *y = x;
printf("%d\n", y);
return 0;
}
I don't understand this. How can the literal 576 be type-casted to a void pointer? Additionally, notice how in the printf() function call, the dereference operator is missing from y. And yet it prints the value 576. And when I add the dereference operator to y, nothing prints to the terminal.
After a bit of research, I found out that NULL is just the literal 0 type-casted to a void pointer. Can anything be type-casted to a void pointer? Is the code I posted up dangerous?