Structures in C are similar to records in Pascal. For example:
struct gun
{
char name[50];
int magazinesize;
float calibre;
};
struct gun arnies;
defines a new structure gun and makes arnies an instance of it.
NOTE: that gun is a tag for the structure that serves as shorthand for future declarations. We now only need to say struct gun and the body of the structure is implied as we do to make the arnies variable. The tag is optional.
Variables can also be declared between the } and ; of a struct declaration, i.e.:
struct gun
{
char name[50];
int magazinesize;
float calibre;
} arnies;
struct's can be pre-initialised at declaration:
~struct gun arnies={"Uzi",30,7};
which gives arnie a. Uzi with 30 rounds of ammunition.
To access a member (or field) of a struct, C provides the . operator. For example, to give arnie more rounds of ammunition:
arnies.magazineSize=100;