[prev] 128 [next]

Pointers and Structures (cont)

General principle …

If we have:

SomeStructType s;
SomeStructType *sp = &s;  // declare pointer and initialise to address of s

then the following are all equivalent:

s.SomeElem    sp->SomeElem    (*sp).SomeElem

[Diagram:Pic/structptr2.png]