struct (keyword)
ֽֽֽֽֽֽֽֽֽֽֽֽֽֽֽֽGroups variables into a single record
struct {
;
...
} ;
A struct, like a union, groups variables into
a single record.
The <struct-type-name> is an optional tag name
that refers to the structure type.
The <structure-variables> are the data
definitions, and are also optional.
Though both are optional, one of the two must
appear.
Elements in the record are defined by naming a
<type>, followed by <variable-names> separated
by commas. Different variable types can be
separated by a semicolon.
For example,
struct my_struct {
char name, phone_number;
int age, height;
} my_friend;
declares an array of records containing two
strings (name and phone_number) and two
integers (age and height).
To access elements in a structure, you use a
record selector (.). For example,
strcpy(my_friend.name,"Mr. Wizard");
To declare additional variables of the same
type, you use the keyword struct followed by
the <struct-type-name>, followed by the
variable names. For example,
struct my_struct my_friends;