Skip to content

Latest commit

 

History

History
36 lines (22 loc) · 1.99 KB

File metadata and controls

36 lines (22 loc) · 1.99 KB

Get_next_line

42 School
get_next_line is a project I developed as part of my journey through 42, with the goal of implementing a C function able to read from a file descriptor line by line. This function returns a new line on each call, efficiently managing memory and intermediate buffers. One of the main challenges was handling partial reads and preserving leftover data between successive calls, ensuring that each line is delivered completely.

My solution is designed to work correctly with any valid file descriptor and properly handles special cases such as end-of-file (EOF) and various errors. I achieved all this while respecting strict constraints on allowed functions. Through this project, I deepened my understanding of static variables, buffer management, and low-level file I/O operations in C.


📁 Project Structure


⚙️ Compilation

To manually compile the files for this project, I usually use the following command:

gcc -Wall -Wextra -Werror -D BUFFER_SIZE=42 get_next_line.c get_next_line_utils.c -o gnl

You can change the value of BUFFER_SIZE to suit your needs.


🚀 Usage

Include the header file in your own program and use the get_next_line function by passing an open file descriptor in read mode.
Each time you call the function, you will receive the next available line, until you reach the end of the file.


This project was completed as part of the 42 curriculum.