void Pointers Definition
Learn about void pointers, a key concept for implementing genericity in C.
We'll cover the following...
Introduction
Up until this point, we’ve worked with various pointer types, such as:
- Pointers to
int
- Pointers to
float
- Pointers to
char
- Pointers to custom data types, defined using structures
One limiting factor was that different pointer types are not often compatible. For example, an int
pointer can’t usually point to a floating point number. This fact introduces an interesting problem. The problem is what happens when we want to write a function that doesn’t depend on the data type, as the processing is identical. We’d have to create multiple almost identical functions, where the only difference is the data type of the arguments.
For example, let’s look at the memcpy
function. Its purpose is to copy ...