Skip to content

Get_Next_Line (42cursus) This project aims is to code a function that return a line ended by a carriage return read in a file descriptor.

Notifications You must be signed in to change notification settings

ablaamim/Get_Next_Line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 

Repository files navigation

Get_next_line 1337's PROJECT :


Reading a line on a fd is way too tedious

In this repo you will find all the codes developed during the get_next_line 1337's project, both mandatory's part and bonus part.


ablaamim's


Mandatory

Calling the function get_next_line in a loop will then allow you to read the text available on the file descriptor one line at a time until the end of it. The function should return the line that has just been read. If there is nothing else to read or if an error has occurred it should return NULL.


Bonus

To succeed get_next_line with a single static variable. To be able to manage multiple file descriptors with your get_next_line. For example, if the file descriptors 3, 4 and 5 are accessible for reading, then you can call get_next_line once on 3, once on 4, once again on 3 then once on 5 etc. without losing the reading thread on each of the descriptors


The project

Header files :

Mandatory :

	MANDATORY ALGORITHM :

	GET_NEXT_LINE

	DESCRIPTION :
	Write a function which returns a line read from a
	file descriptor.

	RETURN VALUES :

	Read line: correct behavior.
	NULL: nothing else to read or an error occurred.

🔧 Nothing but libft functions !


ℹ️ This repository contains two versions of get_next_line, both works flawlessly.

Usage

Requirements

get_next_line requires gcc compiler and some standard libraries.

Instructions

Clone this repository in your local computer:

git clone https://github.com/ablaamim/Get_Next_Line.git

To use the library in your code you will need to include the header:

#include "get_next_line.h"

or

#include "get_next_line_bonus.h"

To compile the program, use these flags:

Make sure to change the XX after BUFFER_SIZE to the buffer size you want the program to work with.

gcc -Wall -Wextra -Werror -D BUFFER_SIZE=XX path/to/main_function.c path/to/get_next_line.c path/to/get_next_line_utils.c -I path/to/get_next_line.h 

About

Get_Next_Line (42cursus) This project aims is to code a function that return a line ended by a carriage return read in a file descriptor.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages