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.
Checking what this lesson needs for you…
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