It would be hard for a program to manipulate data if it were scattered
around with no particular structure. C therefore has several facilities
to group data together in convenient packages, or data structures.
One type of data structure in C is the struct (or
structure) data type, which is a group of variables clustered
together with a common name. A related data type is the union,
which can contain any type of variable, but only one at a time.
Finally, structures and unions can be linked together into complex data
structures such as lists and trees. This chapter explores all of these
kinds of data structure.
It is important to distinguish the terms structure and data
structure. "Data structure" is a generic term that refers to any
pattern of data in a computer program. An array is a data structure, as
is a string. A structure is a particular data type in C, the
struct; all struct variables (structures) are data
structures, but not all data structures are structures.