CHAPTER 21 / 26
C Structures
Learn how structures group different types of data together.
01 — Syntax
struct Name {\n data_type member;\n};02 — Example
#include <stdio.h>
struct Student {
char name[30];
int age;
};
int main() {
struct Student s = {"Aman", 20};
printf("%s %d", s.name, s.age);
return 0;
}03 — Important Points
- Structures can group related data.
- Access members with the dot operator for normal structure variables.
04 — Common Mistakes
- Using the wrong member name.
- Forgetting the struct keyword where required.
05 — Real-World Use
Structures are used to model records such as students, employees and device data.
06 — Practice
Create a small program that demonstrates the main idea of C Structures.