Structures are extremely powerful data types. Not only can you pass a
whole structure as a parameter to a function, or return one as a value
from a function. You can even assign one structure to another.
You can get and set the values of the members of a structure with the
. dot character. This is called the member operator. The
general form of a member reference is:
structure_name.member_name
In the following example, the year 1852 is assigned to the
year_of_birth member of the structure variable person1, of
type struct personal_data. Similarly, month 5 is assigned to the
month_of_birth member, and day 4 is assigned to the
day_of_birth member.
Besides the dot operator, C also provides a special -> member
operator for use in conjunction with pointers, because pointers and
structures are used together so often. (See Pointers to structures.)
Structures are easy to use For example, you can assign one structure to
another structure of the same type (unlike strings, for example, which
must use the string library routine strcpy). Here is an example
of assigning one structure to another:
Of course, random_person is a good name for the variable returned
by this bare-bones function, because without unless one writes code to
initialize it, it can only be filled with garbage values.