1 2 3 4 5 6

*

So with our example name struct we could create variables fred and andrew as follows:

struct Person fred, andrew;

This declaration creates two variables (called fredand
andrew) and allocates space for them. Each variable
(structure) has two elements, each element points to an
array of characters that may be used to hold the first
and last names, respectively.
We use the.(dot) operator to form individual instances of
a structure element. For example:

fred.first = "Fred";
fred.last= "Flintstone";

equally one might write

andrew = {"Andrew", "Choi"};

*

The .(dot) operator is used to extract the individual elements from a structure variable. In the case of our Person structure we have:

char* FirstName;
char* LastName;
FirstName = andrew.first
LastName= andrew.last

January 24, 1999

Page 2

copyright University of Alberta