Skip to content

LucasDatilioCarderelli/02-get_next_line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get_next_line

Project develop for 42Cursus

Linkedin GitHub code size in bytes Number of lines of code

Goal

This project will not only allow you to add a very convenient function to your collection, but it will also allow you to learn a highly interesting new concept in C programming: static variables

Description

May it be a file, stdin, or even later a network connection, you will always need a way to read content line by line. It is time to start working on this function, which will be essential for your future projects.

Objectives:

  • Unix logic

Skills:

  • Unix
  • Rigor
  • Algorithms & AI

Brief

Write a function which returns a line read from a file descriptor

Prototype

char *get_next_line(int fd);

Parameters

File descriptor to read from

Return

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

External functs

read(2)
malloc(3)
free(1)

Bonus Part

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.

Releases

No releases published

Packages

No packages published