Struct data ype
There are many situations in which many variables are related to each other, with the values stored in each variable are pieces of information belonging to one object or entity. It would be desirable to have a way to store that information in a cohesive way, without having to resort to using many unique variables with their relationship achieved through some programmer's defined naming convention. Fortunately, we have structs to allow us to link different data types together in a cohesive way.
In its simplest form a struct is a group or collection of different data types forming a compound data type. Going further on, when we combine structs and pointers, we can build more complex data structures such as linked lists and abstract data types such as stacks.
Two natural questions might arise: "Can struct's members be added or removed at program's runtime?" and "Can structs inherit members from other structs?". Those require new concepts which aren't currently covered in this site. Short answer: no.
To avoid confusion:
- A struct is not a variable, it's a compound data type;
- The difference between local and global scopes does apply to structs.
To understand structures not much more knowledge than simple variables and arrays is required