Skip to content

This project is about programming a function that returns a line read from a file descriptor.

Notifications You must be signed in to change notification settings

ZakariaElbouzkri/42get_next_line

Repository files navigation

# 📖 1337_get_neext_line

Reading a line on a fd is way too tedious

GitHub code size in Kilo bytes Number of lines of code Code language count


💡 About the project

The aim of this project is to make you code a function that returns a line, read from a file descriptor.

You will understand how files are opened, read and closed in an OS,
and how they are interpreted by a programming language for further analysis.
This task is crucial to understand for a future programmer since much of the time is based
on manipulating files for data management and persistence.
This project consists of coding a function that returns one line at a time from a text file.

🛠️ Usage

Requirements

The function is written in C language and thus needs the gcc compiler and some standard C libraries to run.

Instructions

1. Using it in your code

To use the function in your code, simply include its header:

#include "get_next_line.h"

OR:

#include "get_next_line_bonus.h"

For bonus part to from multiple file descriptors at the same time .

and, when compiling your code, add the source files and the required flag:

get_next_line.c get_next_line_utils.c -D BUFFER_SIZE=<n>

Returns

  • Readed Line : correct beahviore
  • NULL : if Nothing else to read or an error occured

📋 Testing

You only have to edit the get_next_line.c file and uncomment the main function and headers inside it. You can edit test.txt files to put another text if you wish to test othe cases. Then simply run this command (change "xx" with desired buffer size) :

gcc -Wall -Werror -Wextra get_next_line.c get_next_line_utils.c -D BUFFER_SIZE=n && ./a.out

Or you can also use this third party tester to fully test the project

About

This project is about programming a function that returns a line read from a file descriptor.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages