This project aims to develop the get_next_line function, capable of reading lines with a limited buffer size from a file descriptor. This project is written in C.
get_next_line.h: Header file containing the prototype of theget_next_linefunction.get_next_line.c: Implementation of the main function.get_next_line_utils.c: Utility file containing additional functions necessary for the implementation ofget_next_line.
- Development of a complex function in the C language.
- Adherence to the
42 SchoolC coding standard to ensure code quality and readability. - Robust handling of undefined behaviors and error cases.
- Makefile to automate the project compilation.
- Use of flags
-Wall,-Wextra, and-Werror. - Use of flags
-g3and-fsanitize=addressfor debugging.
- Dynamic memory allocation using
malloc. - Freeing memory once operations are completed or in case of errors to prevent leaks.
- Use of
valgrindto check for residual memory leaks.
- Reading and storing strings.
- Parsing the string to check for the end of a line defined by a newline character
\nor end of fileEOF. - Reuse of the file descriptor to read the file line by line once the function is recalled, returning the remainder of the previous line if a newline is found.
- Definition of a
BUFFER_SIZEbefore compilation to set a constant buffer size. - Use of a static variable to store the remainder of the previous line if a newline is found.
- Reading lines from a file descriptor.
- Handling various use cases, such as end of file or reading errors.
- Multiple file descriptors handling with a constant array of strings.