[Solved] How fgets reads line after line from a file?


EDIT: added extra explanation as @KlasLindbäck pointed out that my answer wasn’t entirely correct

The File is a struct that contains a field “fd” which is an integer that identifies the OS file descriptor of this file, this file descriptor can be used to retrieve the current location in the file you’re reading. If you want more information about the File struct here and file descriptor here

TL;DR: The FILE struct somehow stores where it’s reading.

2

solved How fgets reads line after line from a file?