Module 13 · Files
Binary Files, fread and fwrite
Free with an accountReading
Kenji's racing game saves his best lap: 83.456789 seconds. He wants a small save file, so he writes the time with %.2f, the way lesson 3 wrote numbers. The next day the game loads 83.46. His record got slower overnight, without a single lap.
Checking what this lesson needs for you…
What is inside Binary Files, fread and fwrite
- Text rounds the number, bytes keep it
- fwrite and fread copy bytes
- The counts they return
- fseek and ftell: the file position
- A record by its index
- A binary file is not portable
- Text or binary: how to choose