Next: Common Pointer Pitfalls Up: Pointers Previous: Static Initialisation of Pointer Arrays

Pointers and Structures

These are fairly straight forward and are easily defined. Consider the following:

the operator lets us access a member of the structure pointed to by a pointer.i.e.:

pt_ptrx = 1.0;

pt_ptry = pt_ptry - 3.0;

Example: Linked Lists

Fig. Linking Two Nodes

NOTE: We can only declare next as a pointer to ELEMENT. We cannot have a element of the variable type as this would set up a recursive definition which is NOT ALLOWED. We are allowed to set a pointer reference since 4 bytes are set aside for any pointer.

The above code links a node n1 to n2 (Fig. ) we will look at this matter further in the next Chapter.
Fri May 20 13:40:49 BST 1994