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.
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 fprintf, fscanf and Formatted File Input and Output
- fprintf writes formatted text to a file
- fscanf reads fields back and returns a count
- sscanf reads the same fields from a string
- fgets then sscanf: a bad line costs one line
- A scanset reads a field up to a comma
- Records into an array of structs, and a table back out