Prev NEXT

The Basics of C Programming

Advanced Pointers

You will normally use pointers in somewhat more complicated ways than those shown in some of the previous examples. For example, it is much easier to create a normal integer and work with it than it is to create and use a pointer to an integer. In this section, some of the more common and advanced ways of working with pointers will be explored.

Pointer Types

It is possible, legal, and beneficial to create pointer types in C, as shown below:

Advertisement

typedef int *IntPointer;
...
IntPointer p;

This is the same as saying:

int *p;

This technique will be used in many of the examples on the following pages. The technique often makes a data declaration easier to read and understand, and also makes it easier to include pointers inside of structures or pass pointer parameters in functions.