Programs that forget everything when they exit are limited. Files let your program save data and load it back later, and they are also where things most often go wrong: a file may be missing, locked, or full. This module covers both sides.
It starts with the basics of file I/O: opening a file with fopen, writing and reading its contents, and closing it again. It then turns to error handling. C has no exceptions, so you check return codes, read errno, and report problems with perror and strerror.
Watch the lessons in order, then continue on to Preprocessor, Headers & Build Tools.
A tutorial on file handling in C covering how to create, open, read, write, and close a file.
The freeCodeCamp C course chapter on writing data to a file from your program. Starts at the 3:32:37 mark.
The freeCodeCamp C course chapter on reading data back from a file. Starts at the 3:41:52 mark.
An introduction to handling errors in C: using return codes, errno, and best practices.
How to check for failures, report them, and make your C programs more reliable with perror and strerror.