An open API service indexing awesome lists of open source software.

https://github.com/ekkoz897/42cursus_get_next_line

This is a 42 school project meant to teach us how to read from a file descriptor without knowing it's size before hand making use of static variables.
https://github.com/ekkoz897/42cursus_get_next_line

42born2code 42cursus 42projects 42school c file-descriptors get-next-line getnextline gnl gnl42 read static-variables

Last synced: 2 months ago
JSON representation

This is a 42 school project meant to teach us how to read from a file descriptor without knowing it's size before hand making use of static variables.

Awesome Lists containing this project

README

        


42cursus_get_next_line


Reading a line on a fd is way too tedious


About
ยท
Usage
ยท
Testing

---

## ๐Ÿ’ก 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:

```C
#include "get_next_line.h"
```

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

```shell
get_next_line.c get_next_line_utils.c -D BUFFER_SIZE=
```

## ๐Ÿ“‹ 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) :

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

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

* [Tripouille/gnlTester](https://github.com/Tripouille/gnlTester)