Home Segments Index Top Previous Next

411: Mainline

You define global pointer variables just as you define other global variables, except that an asterisk appears in the definition when you define a global pointer variable:

double d;       // Allocate space for a double variable 
double *dptr;   // Allocate space for a pointer to a double variable 
cylinder c;     // Allocate space for a cylinder 
cylinder *cptr; // Allocate space for a pointer to a cylinder 

The definition double *dptr; makes dptr a pointer variable, and the chunk of memory allocated for dptr is expected to contain the address of a chunk of memory allocated for a floating-point number of type double.

Thereafter, dptr, without an asterisk, identifies the location of an address; *dptr, with an asterisk, identifies the location of the floating-point number identified by the address.