Learn C Programming

Lesson 2 of 9 ¡ Files

Module 13 ¡ Files

Reading and Writing Text Files

Free with an accountReading

Every evening Maria's till program writes one line: the day, and how many sales it made. She wants a log, a list that grows by one line a day.

Sign in to read

This lesson is free, with an account

An account costs nothing and opens every lesson in this track that is not marked Pro, on every device you read on.

What is inside Reading and Writing Text Files

  1. Write lines, then read them back
  2. fgets keeps the newline
  3. Append mode: the log grows at the end
  4. The file position, and rewind
  5. One function for a file and for stdin