get_next_line is a project from 42 School designed to develop a function that reads a file descriptor line by line, returning one line per call without loading the entire file into memory.
The goal of this project is to write a function get_next_line that reads from a file descriptor and returns the next line each time it is called. It handles reading arbitrarily long lines efficiently by reading the file in chunks defined by BUFFER_SIZE.
- Reads one line at a time from a file descriptor
- Supports multiple file descriptors simultaneously (in bonus part)
- Handles files of any size without memory overflow
- Works with any BUFFER_SIZE value
gcc -Wall -Wextra -Werror -D BUFFER_SIZE=42 get_next_line.c get_next_line_utils.c -o gnl- get_next_line.c — main function implementation
- get_next_line_utils.c — helper functions
- get_next_line.h — header file with function prototypes and macros
- Bonus part is very similar with mandatory except bonus part handles multiple file descriptors simultaneously.
- Used only allowed functions: read(), malloc(), and free()
- No leaks or crashes — memory is managed carefully
- The function is efficient and handles edge cases