C - Pointer Pointer Introduction


Variables that can store addresses are called pointers.

The address that's stored in a pointer is usually that of another variable.

You can have a pointer point_number that contains the address of another variable, called number.

Each type has its own type of pointer.

The pointer can be used only to point to variables of that type.

So pointers of type "pointer to int" can point only to variables of type int.

Pointers of type "pointer to float" can point only to variables of type float.

In general a pointer of a given type is written type* for any given type name type.

The type name void means absence of any type, so a pointer of type void* can contain the address of a data item of any type.

Type void* is used as a parameter type or return value type for data in a independent type.

Any kind of pointer can be passed around as a value of type void* and then cast to the appropriate type when you come to use it.

Related Topics