# Week 10

:::{topic} Learning goals
- read & write to file.
- differentiate between a file and stream
- select correct file-opening mode for the intended operation.
- use the return values of `fgets` to loop through a stream
- explain the responsibilities of the file IO functions `fgets` & `fputs` regarding buffer management
  - justify why `fgets` needs a size compared to `fputs`
- differentiate between the three streams `stdin`, `stdout` and `stderr`.
:::
<!--
- differentiate between sequential and random access to files
- print informative error messages using `perror()`. => did not have time for this
-->

:::{toctree}
:maxdepth: 1
week10/filter-csv-by-age
week10/sequential-io-with-stdin-stdout
week10/streams
:::

<!--
TODO: The seven questions in the activity took a lot of time. I could barely scratch the streams.md

Program that searches for prime numbers, but a more interesting example? that writes checkpoints.

What is the advantage of files?

Using and assignment in a loop control expression
 while (
      (fgets_return = fgets(line, LINE_MAX, istream))
  ) {

I did not cover:
- random access
- binary access


I used #define USAGE (instead of const char), but on some Windows computers the syntax highlighting did not work. Try it yourself.
-->