Guided Notes

Structs & Enums

Grouping data with structs, typedef, arrays of structs, structs and pointers (->), nested structs, and enums.

Structs

Slide 1 / 5

A struct groups related values under one name:

struct Student { char name[50]; int score; };

struct Student s = {"Ana", 91}; printf("%s: %d\n", s.name, s.score);

• Access members with the dot: s.score. • Structs can be copied with = (all members are copied). • Each member has its own type — structs model records: a product, an employee, a point.

← Functions & Recursion