Skip to main content

Checkpoint: mmap Line Counter

Challenge on lesson: Checkpoint: mmap Line Counter

CHALLENGE
Difficulty: advanced+25 XP

POSIX. Implement long count_lines_mmap(const char *path) โ€” open, fstat, mmap PROT_READ MAP_PRIVATE, count newline bytes, munmap, close; return the count. Empty file returns 0. Any failure (open/fstat/mmap) returns -1. A trailing newline produces no extra phantom line beyond the newlines actually counted.

Back to lesson: Checkpoint: mmap Line Counter