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

04 — Common Mistakes

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.

▶ Try It Yourself← PreviousNext →All Chapters