Pointers

A pointer type variable holds the address of a data object or a function. A pointer can refer to an object of any one data type; it cannot refer to a bit field or a reference.

Some common uses for pointers are:

Note that the placement of the type qualifiers volatile and const affects the semantics of a pointer declaration. If either of the qualifiers appears before the *, the declarator describes a pointer to a type-qualified object. If either of the qualifiers appears between the * and the identifier, the declarator describes a type-qualifed pointer.

The following table provides examples of pointer declarations.

Table 14. Pointer declarations
Declaration Description
long *pcoat; pcoat is a pointer to an object having type long
extern short * const pvolt; pvolt is a constant pointer to an object having type short
extern int volatile *pnut; pnut is a pointer to an int object having the volatile qualifier
float * volatile psoup; psoup is a volatile pointer to an object having type float
enum bird *pfowl; pfowl is a pointer to an enumeration object of type bird
char (*pvish)(void); pvish is a pointer to a function that takes no parameters and returns a char

Related information