dpiza / get_next_line

Reading a line on a fd is way too tedious

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Get Next Line

42-BadgeC-Badge42Unlicense

Description

This project aims to code a function that returns a line, read from a file descriptor.

Goals

This project will not only add a very convenient function into the library, but it will also require the use of a highly interesting new concept in C programming: static variables.

Mandatory

• Calling your 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.

• Your 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.

Usage

Include the header:

#include "get_next_line.h"

A file description must be provided to the function.

get_next_line(fd);

Add the BUFFER flag when compiling the code:

-D BUFFER_SIZE=XX

License

This work is published under the terms of 42 Unlicense

About

Reading a line on a fd is way too tedious

License:Other


Languages

Language:C 100.0%