← C Programming learning pathC Programming · Module 8 of 10
Structures
Group related variables of different types with struct.
📖 Key ideas
- struct Student { int roll; char name[30]; float marks; }; defines a new type.
- Access members with the dot: s.roll.
- With a pointer, use the arrow: p->roll.
- typedef gives a shorter name: typedef struct Student Student;
- Arrays of structs store many records.
💡 Real-life example: A struct is a student ID card: roll number, name and marks together in one card.
structGroups variables into one type
.Accesses a member of a struct variable
->Accesses a member through a pointer
typedefCreates a type alias