get_next_line
is a project at 42 that introduces dynamic file reading in C. The goal is to implement a function capable of reading a file line by line, regardless of the length of the lines or the BUFFER_SIZE
used for reading.
This project deepens the understanding of file descriptors, static variables, dynamic memory management, and efficient buffer handling.
get_next_line
implements the ffollowing functionalities :
The function get_next_line(int fd)
is capable of :
- Reading from a file descriptor (fd).
- Extracting one complete line at a time, including the newline (\n).
- Managing multiple file descriptors simultaneously.
- Preserving the remainder of the buffer for the next call.
- Uses static storage to retain unprocessed data between function calls.
- Efficiently handles concatenation of partial reads with
ft_strjoin()
. - Uses
ft_memmove()
(or other function) to shift remaining data in the buffer after extracting a line. - Ensures proper memory allocation and freeing to prevent leaks.
get_next_line.c
→ Contains the main functionget_next_line()
.get_next_line_utils.c
→ Includes helper functions for memory operations and string handling.
A special thanks to Axiaaa for her help. 🙏