Reading a line from a file descriptor
Start date: 09/august/2021
Project status: completed 105/100 points
Write a project with maximum of 10 functions under the 42 norminette restrictions, that reads one line from a file descriptor with varying BUFFER_SIZE. Thereby, only one line should be returned and any remains after the newline should be saved for a repetitive function call.
Requirements
- Repeated calls (e.g., using a loop) to get_next_line() function should read the text file pointed to by the file descriptor, one line at a time.
- The function should return the line that was read. If there is nothing else to read or if an error occurred, it should return NULL.
- Function should work as expected both when reading a file and when reading from the standard input.
- The returned line should include the terminating \n character, except if the end of file was reached and does not end with a \n character.
- lseek() is forbidden.
- Global variables are forbidden.
Key learning points
- Learning about file descriptors and reading from a file
- Using static variables
clone the repository:
git clone https://github.com/KHammerschmidt/42cursus-get_next_line &&
cd 42cursus-get_next_line &&
git clone https://github.com/KHammerschmidt/42cursus-Libft
to modify the buffer size used by read() adapt BUFFERSIZE value n in
Makefile
CPPFLAGS := -D BUFFER_SIZE=n
to compile the project:
make