Is it possible to dereference the void pointer without type-casting in C programming language?
Also, is there is any way of generalizing a function which can receive a pointer and store it in void pointer and by using that void pointer we can make a generalized function?
for e.g.
void abc(void *a, int b)
{
if(b==1)
printf("%d",*(int*)a); // If integer pointer is received
else if(b==2)
printf("%c",*(char*)a); // If character pointer is received
else if(b==3)
printf("%f",*(float*)a); // If float pointer is received
}
I want to make this function generic, without using ifs; is it possible?
Also if there are some internet articles which explain the concept of void pointer, then it would be beneficial if you could provide the URLs.
Also, is pointer arithmetic with void pointers possible?