PROJECT DOSSIER // [GET NEXT LINE]VIEW SOURCEBACK TO PROJECTS →

01 // PROJECT AT A GLANCE

GET NEXT LINE

C

Reading a file line by line when the system only knows how to read blocks of bytes.

One of the most famous projects of the curriculum, because it looks simple and is not. The operating system has no notion of a « line »: it returns packets of bytes of a size you choose. The project consists in building, on top of that, a function that returns one complete line per call — remembering, from one call to the next, what has already been read in excess.

A get_next_line function returning one complete line per call, on top of read(), with a persistent buffer and a read size configurable at compile time.

PRIMARYC
DELIVERYTEAM RECORD
VERIFICATIONCriterion
SOURCEINSPECTOR READY
MEDIA ATTACHMENTS (Images, Photos, Videos)

03 // KEY OUTCOMES

  • Building a « line » abstraction on top of an API that only knows bytes
  • Works whatever the buffer size, including 1 byte
  • A subject reputed to be simple that catches everyone on the same point: what stays in memory between two calls

BEYOND THE BRIEF

  • Criterion tests with dedicated data sets (data.txt, void.txt) covering the empty file and the file with no trailing newline

04 // SOURCE TREE

READING SOURCE…