you can think of it as a raw pointer, nothing more than an address, think about it, pointers are nothing more than address right, so they should all be of equal size, either 32 or 64 bits in most modern systems but if thats the case why do we say int *
or char *
or so on if they are all the same size, well thats because we need of a way to interpret the type we are pointing to, int *
means when we dereference go to that address and interpret the 4 bytes as an int
or char *
means when we dereference go to that address and get a byte, so what happens when you dereference a void *
well you get warning: dereferencing ‘void *’ pointer
basically we really can't and if you do its affects are compiler dependent, the same applies when we do arithmetics on it.
So why bother using them? well I personally don't and some groups dont particularly like them, fundamentally they allow you to create fairly generic subroutines, a good example would be memset
which sets a block of memory to a certain byte value, its first argument is a void *
so it won't complain whether giving a char *
or int *
due note that it works on a per byte basis, and you need to properly calculate the total size of the array.