Module 13 · Files
EOF, Errors, and Closing What You Opened
Free with an accountReading
Bob writes a small tool that prints Maria's sales file on the screen. The file has three lines. The screen shows four: the last sale appears twice.
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 EOF, Errors, and Closing What You Opened
- Bob's loop prints the last line twice
- Test the read, not feof
- After the loop: the end, or an error?
- fclose can fail, so check what it returns
- A written line waits in a buffer
- How a program ends decides what is saved