Learn C Programming

Lesson 3 of 9 · Files

Module 13 · Files

fprintf, fscanf and Formatted File Input and Output

Free with an accountReading

Amara keeps her class's marks in marks.txt, one student a line: a name and three marks. Lesson 2 can print that file. But Amara wants averages, and nobody can add up the text 92.

Checking what this lesson needs for you…

What is inside fprintf, fscanf and Formatted File Input and Output

  1. fprintf writes formatted text to a file
  2. fscanf reads fields back and returns a count
  3. sscanf reads the same fields from a string
  4. fgets then sscanf: a bad line costs one line
  5. A scanset reads a field up to a comma
  6. Records into an array of structs, and a table back out