The question is a bit broad, but ...
A structure is an aggregate or composite data type used to represent objects that are described by several attributes of potentially different types. Some examples:
- A point in three-dimensional space represented by 3 real coordinates x, y and z;
- Postal address indicated by street name, house or apartment number, city, state, postal code;
- -, , , ;
- A node , , , ;
.. .. ..
. :
struct Address {
char *streetName;
int buildingNumber;
char *aptNumber;
char *city;
char state[3];
int zip;
};
:
struct Address newAddress;
:
struct Address *addrPtr = &newAddress;
. -> , struct struct:
newAddress.streetName = strdup("Elm");
addrPtr->buildingNumber = 100;
...
- , .