Files and reliable programs
Keeping data after a program ends, and recognising the mistakes that C will let you make.
About 6 hours of study
Learning objectives
- Read and write files safely
- Handle a file that cannot be opened
- Recognise undefined behaviour
- Use warnings and sanitizers
Lessons
- 1
Reading and writing files Intermediate
Keep data after a program ends: open files with fopen, write with fprintf, read with fscanf and fgets, and handle a file that cannot be opened.
- 2
Bugs C will not catch Intermediate
Undefined behaviour: what real C does silently, and how to spot each bug before it bites.
Module practice
- C: Write numbers, read them backEasy
- C: Lines in a fileMedium
- C: A tiny file managerHard
- C: Fix the totalEasy
- C: Fix the overrunMedium
- C: Fix the vanishing arrayHard