4 AnswersNew Answer
As pointed out by Disvolviĝo; You may wonder why and when you'd want to do that - Basically when you are dealing with generic data, or better compatibility with C code (e.g. malloc returns void pointers).
int a = 100; void *ptr = &a; cout << *(int*)ptr << endl; //100 If you cast it, you can use it. It is used when you wanna receive any type variables.
it used to make generic functions for example sort() is generic in stdlib.h it receives a pointer to function that takes two const void* l and returns int like int compare(const void*,const void*); the same parameters and return type to several functions that compares two variables that we don't know how to compare them or what is the type of them
is it good to donot use void pointer or better way to typecast void pointer