In Lesson 9 of **Learn C With Me**, we begin one of the most practical topics we've encountered so far: **File Input/Output in C**. Using **Beej's Guide to C**, we learn how C represents open files using `FILE *`, how to open and close files, and how to read and write text data using standard library functions. We cover: * What **file input/output** means in C * The **`FILE *` data type** and the concept of streams * The standard streams `stdin`, `stdout`, and `stderr` * Why `stdout` and `stderr` are separate streams * A quick look at **shell redirection** * **Text and binary streams** * Opening files with `fopen()` * File modes such as `"r"`, `"w"`, and `"a"` * Closing files with `fclose()` * Reading characters with **`fgetc()`** * Understanding **EOF** * Why `fgetc()` returns an `int` instead of a `char` * Reading lines with **`fgets()`** * Using a character array as an input buffer * What happens when a line is larger than the buffer * **Formatted file input** with `fscanf()` * Reading multiple values from structured text files * Why `scanf`-style functions require care with untrusted input * Limiting string field widths to help avoid buffer overflows * Opening a file for writing * How `"w"` mode truncates an existing file * Writing characters with **`fputc()`** * Writing strings with **`fputs()`** * Writing formatted output with **`fprintf()`** One important idea in this lesson is that C treats files as **streams**. The same model applies to `stdin`, `stdout`, and `stderr`. We spend plenty of time experimenting with **`fgets()`** and buffer sizes, and later see how careless use of **`fscanf()`** can cause buffer overflows and why field widths matter. Finally, we start **writing text files** using `fputc()`, `fputs()`, and `fprintf()`. As usual, we experiment, make predictions, make mistakes, get help from the live chat, and try to understand **what C is actually doing** rather than simply memorizing function calls. This is **Part One of File Input/Output**. We stop just before **Binary File I/O**, which we'll continue in the next lesson. This is an **interactive, follow-along live course**. I am learning C alongside you, so expect questions, mistakes, experiments and plenty of discussion. No passive watching here — participate in the chat and work through the examples with us. 00:00:00 Starting the stream 00:05:08 Recap & today's topic: File I/O 00:23:53 The FILE * data type 00:25:57 stdin, stdout & stderr 00:31:22 Reading text files 00:32:58 Opening our first file 00:46:16 Understanding fopen() and file modes 00:53:38 Closing files with fclose() 00:55:24 Reading a file character by character 00:56:12 EOF and why fgetc() returns int 01:07:25 Reading lines with fgets() 01:45:11 Experimenting with fgets() buffer sizes 02:14:11 Formatted input with fscanf() 02:45:18 Writing text files 02:48:08 fputc(), fputs() & fprintf() 03:02:09 Binary File I/O postponed to next lesson 03:03:44 Post-stream chat 📅 **We go live every Saturday at 19:00 CEST** — interactive, follow-along C programming sessions. 📖 **Study material:** [Beej's Guide to C](https://beej.us/guide/bgc/) 📚 **Course materials:** [Linux Renaissance C Programming Course](https://linuxrenaissance.com/courses) 💬 **Homework & discussion:** [Linux Renaissance Forum](https://forum.linuxrenaissance.com/c/programming/13) 📺 **All C Programming lessons:** [C Programming playlist](https://www.youtube.com/playlist?list=PLE6A_ADcHGpc) 🔴 **This stream is proudly sponsored by OPNsense** — the open source firewall and routing platform trusted by professionals worldwide. [OPNsense](https://opnsense.org) ### Support Linux Renaissance 🛒 Shop: [Linux Renaissance Shop](https://shop.linuxrenaissance.com) ☕ Ko-fi: [Ko-fi](https://ko-fi.com/darth) 🎖️ Patreon: [Patreon](https://www.patreon.com/c/linuxrenaissance/membership) ▶️ YouTube membership: [YouTube Membership](https://youtube.com/@LinuxRenaissance/join) ### Find me elsewhere 🌐 Blog: [Linux Renaissance](https://linuxrenaissance.com) 🎥 PeerTube: [Linux Renaissance on PeerTube](https://watch.linuxrenaissance.com) 📺 Odysee: [Linux Renaissance on Odysee](https://odysee.com/@LinuxRenaissance:1) 🎮 Twitch: [Linux Renaissance on Twitch](https://twitch.tv/LinuxRenaissance) 💬 Matrix: [Linux Renaissance Matrix space](https://matrix.to/#/%23space%3Afosshq.org)