Structs let you model things: a student, a point, a product.
Direct answer
A struct groups related variables, called members, into a single type. Access members with . or, through a pointer, ->. Use typedef to avoid repeating the struct keyword.
Example
#include <stdio.h>
#include <string.h>
typedef struct {
char name[30];
int age;
} Person;
void birthday(Person *p) {
p->age++;
}
int main(void) {
Person ada = {"Ada", 28};
birthday(&ada);
printf("%s is %d\n", ada.name, ada.age);
return 0;
}
Arrays of structs
Person team[3] = {{"A", 20}, {"B", 25}, {"C", 30}};
for (int i = 0; i < 3; i++) printf("%s\n", team[i].name);
Tips
- Pass large structs by pointer to avoid copying.
- Initialise all members.
Where Teyro fits
Teyro's C for Beginners course turns this into short lessons you can play in a few minutes a day. It has 78 lessons, and you can start free.
The bottom line
Structs are the first step toward organised C programs.


