https://github.com/achrafelkhnissi/get_next_line
This project is about programming a function that returns a lineread from a file descriptor.
https://github.com/achrafelkhnissi/get_next_line
1337school 42cursus 42projects 42school gnl gnl42
Last synced: 7 months ago
JSON representation
This project is about programming a function that returns a lineread from a file descriptor.
- Host: GitHub
- URL: https://github.com/achrafelkhnissi/get_next_line
- Owner: achrafelkhnissi
- Created: 2022-06-02T16:58:05.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-08-28T02:10:32.000Z (about 3 years ago)
- Last Synced: 2025-01-17T07:47:27.496Z (9 months ago)
- Topics: 1337school, 42cursus, 42projects, 42school, gnl, gnl42
- Language: C
- Homepage: https://www.linkedin.com/in/achrafelkhnissi/
- Size: 4.88 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
42cursus' get_next_line
Development repo for 42cursus' get_next_line project
For further information about 42cursus and its projects, please refer to 42cursus repo.
About
·
Index---
## 🗣️ About
> _The aim of this project is to make you code a function that returns a line ending with a newline, read from a file descriptor._
🚀 TLDR: this project consists of coding a function that returns one line at a time from a text file.
## 📑 Index
`@root`
* [**📁 get_next_line:**](get_next_line/) source code developed for the project.
`@/get_next_line/`
_Note: Files suffixed with *_bonus* are exact copies of corresponding files._
**Functions in `get_next_line.c`**
* `get_reminder` - gets the reminder after the newline.
* `check_newline` - returns the index of the newline if found else returns -1.
* `ft_strlen` - find length of string.
* `get_next_line` - main function.**Functions in `get_next_line_utils.c`**
* `ft_strdup` - save a copy of a string (with malloc).
* `ft_calloc` - allocates X size of memory and set it to 0.
* `ft_strjoin` - Joins 2 strings togather.## 🛠️ 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=
```If you're on Linux, you may as well need the following flags:
```shell
-D ARG_MAX="sysconf(_SC_ARG_MAX)" -D OPEN_MAX=1024
```### Third-party testers
* [gnlTester](https://github.com/Tripouille/gnlTester)
* [mrjvs/42cursus_gnl_tests](https://github.com/mrjvs/42cursus_gnl_tests)
* [Hellio404/Get_Next_Line_Tester](https://github.com/Hellio404/Get_Next_Line_Tester)
* [saarikoski-jules/gnl_unit_tests](https://github.com/saarikoski-jules/gnl_unit_tests)
* [charMstr/GNL_lover](https://github.com/charMstr/GNL_lover)
* [Mazoise/42TESTERS-GNL](https://github.com/Mazoise/42TESTERS-GNL)### Notes
- static keyword
- Making a global variable/function static: only visible within its own translation unit.
- static (local variable): presistent across function calls and only visible within its function.note: you cant use the same name for static variable and global static variable! but never do it.