All modules

Advanced -- Module 05

Structures & File Handling

struct and typedef, nested structures, arrays of structs, and file I/O with fopen/fread/fwrite/fprintf for building programs whose data outlives a single run.

Video lesson

Downloadable notes

Plain-text lecture notes for Structures & File Handling.

Download notes (.txt)

Practice problems

Student record CRUD

Define a Student struct and support add/list/delete operations over an array of structs.

Warm-up

CSV to struct array

Read a CSV file line by line with fgets, parse each row into a struct, and print a formatted table.

Core

Binary record store

Write an array of structs to a binary file with fwrite, then read it back with fread and verify a checksum.

Stretch
Try these in the playground →

Module quiz

1. Which keyword lets you create an alias for a struct type?

2. fopen(path, "a") opens a file for:

3. To access a member through a struct pointer p, you use:

4. Forgetting fclose() on a written file risks: