Practice ยท 3 of 3
Sum a File Through mmap
CHALLENGE
Difficulty: advanced+25 XP
POSIX. Implement long sum_bytes_mmap(const char *path) โ open O_RDONLY, fstat for size, mmap PROT_READ MAP_PRIVATE, sum all bytes as unsigned char, munmap, close, return the sum; return -1 on any failure (open/fstat/mmap/munmap). An empty file sums to 0.
Press Submit to check your solution.
Back to lesson: Practice: I/O Mechanics Drills