Converting Pointers
You can either have typed pointers, or the void* pointer. Typed pointers will access the memory as if it is the specified type (this has interesting consequences when you have inheritance with classes, but that will be left for Chapter 4, Classes. Thus, if you cast a pointer to a different type and dereference it, the memory will be treated as containing the cast type. It rarely makes sense to do this. The void* pointer cannot be dereferenced, so you can never access data through a void* pointer, to access the data you have to cast the pointer.
The whole reason for the void* pointer type is that it can point to anything. In general, void* pointers should only be used when the type does not matter to that function. For ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access