In C programming, structures (also called structs) are a way to group several related variables into one place.
Each variable in the structure is known as a member
of the structure. Unlike an array, a structure can contain many different data types. The different variables can be accessed via a single pointer or by the struct declared name which returns the same address.
Declare a Structure:
The general syntax for a struct declaration in C is:
struct name {
type member1;
type member2;
};
Initialize a structure:
Let's assume that we have a structure named player
declared as follow:
struct player {
unsigned int height;
unsigned int width;
unsigned int health_point;
};
You can:
.Define a variable p1
of type player
and initialize its members according to the declaration order in the structure as follow:
struct player p1 = {800, 600, 1200};
/* OR */
struct player p1 = (struct player){800, 600, 1200};
.Use designated initializer style to access each member in a random order:
struct player p1 = {.health_point = 1200, .width = 600, .height = 800};
Note: If an initializer is given or if the object is statically
allocated, omitted elements are initialized to 0.
.Copy the value of an existing object of the same type:
struct player p2 = p1; /* p2 will share the same properties as p1 */
Source:
Wikipedia
Best resources to study this topic:
GeeksForGeeks
OpenClassroom
C advanced doc - DevDocs