void *ptr=10;
This is not valid C, you need an explicit conversion with a cast like (void *) 10
.
printf("%u",ptr);
This is not valid C, you need an explicit conversion with a cast like (unsigned int) ptr
.
Regarding the use of void
pointers, they are generic object pointers, so you can assign a pointer value of any object pointer type to a void *
.
8
solved Can pointers store values and what is the use of void pointers?