Reading and writing files
Open files with fopen, read them with fgets and fscanf, write with fprintf, check for NULL and know why fclose matters, all in C.
- The skill
- Read and write files safely: check that they opened, read them line by line or field by field, and close them.
- You make
- A results summary, a report written and read back, and a high score file that keeps every run.
Premium lesson
£7.99 a month or £59 a year. Cancel any time.
Builds on 22 Pointers to pointers. Free to try: C Foundations and the playground.
Passed
You can now
You have what you need for a project: Text search: your own grep Premium 2.5 hours
Step 1 of 9
exercise_1.c
You've reached the good stuff.
5 exercises in this lesson, checked as you type. Premium opens every lesson after Foundations, in all four courses.
C, 32-bit: int and pointers are 4 bytes