Advantages of void pointers: 1) malloc() and calloc() return void * type and this allows these functions to be used to allocate memory of any data type (just because of void *)
Note that the above program compiles in C, but doesn’t compile in C++. In C++, we must explicitly typecast return value of malloc to (int *). 2) void pointers in C are used to implement generic functions in C. For example compare function which is used in qsort(). Some Interesting Facts: 1) void pointers cannot be dereferenced. For example the following program doesn’t compile.
Void Pointer in C : https://www.geeksforgeeks.org/void-pointer-c-cpp/