void * pointers

C allows pointers to be declared as of type void *, which means that they can be pointed at any type of item. This is useful in defining calloc, malloc etc. but is clearly unsafe if widely used in user programs.

Before a void * pointer can be dereferenced, it must be cast to a pointer of known type, using the usual casting operator (). C makes no check to ensure that this is done consistently and great care must be taken at this point.


Next - Accessing structs and unions via pointers.

Back to Contents page.