Skip to content

A function that returns a line read from a file descriptor.

Notifications You must be signed in to change notification settings

celinenguyentu/GetNextLine

Repository files navigation

GetNextLine

This project is about coding a very convenient function that reads one line at a time from a file descriptor. It should be added to the Libft collection for future projects.

Grade : 125/100
Subjects v.12 : FR EN
42 Norm v.4 : FR EN

Content

char	*get_next_line(int fd)

The function returns a line read from a file descriptor. Consecutive calls returns the consecutive lines one at a time. A line is a sequence of characters ended by a terminating \n character, except if the end of file was reached and does not end with a \n character.
Parameter(s) :
fd - the file descriptor to read from
Return value :
A string containing the next line read. If there is nothing else to read, or an error occured, it returns NULL.

The bonus version can handle multiple files at the same time and read from a different file descriptor per call without loosing the reading thread of each one.

Usage

Include either one of these headers in your code :

#include "get_next_line.h"
#include "get_next_line_bonus.h"

Compile your main.c code using the appropriate files

[ gcc | clang | gcc ] main.c get_next_line.c get_next_line_utils.c
[ gcc | clang | gcc ] main.c get_next_line_bonus.c get_next_line_utils_bonus.c

Testers

I recommend you to code your own tests. It is not only an important part of the learning process but also allows to run thorough tests that might not be included in other people's testers.

I have coded a basic program to run these functions using a various range of test files and allowing to modify the size of the buffer that reads and stores data. Please find it in this repository : GetNextLineTest.

Those are third-party tester to run complementary tests, use them at your own risk :

Releases

No releases published

Packages

No packages published

Languages