https://github.com/khammerschmidt/42cursus-get_next_line
Reading one line from a file descriptor with a varying BUFFER_SIZE.
https://github.com/khammerschmidt/42cursus-get_next_line
static-variables
Last synced: 2 months ago
JSON representation
Reading one line from a file descriptor with a varying BUFFER_SIZE.
- Host: GitHub
- URL: https://github.com/khammerschmidt/42cursus-get_next_line
- Owner: KHammerschmidt
- Created: 2021-10-15T05:40:23.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-12-10T21:24:07.000Z (over 2 years ago)
- Last Synced: 2025-01-12T21:32:58.873Z (4 months ago)
- Topics: static-variables
- Language: C
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
![]()
🧰 get_next_line
Reading a line from a file descriptor
Start date: 09/august/2021
Project status: completed 105/100 points
![]()
![]()
![]()
![]()
## 💡 About the project
> Write a project with maximum of 10 functions under the 42 norminette restrictions, that reads one line from a file descriptor with varying BUFFER_SIZE. Thereby, only one line should be returned and any remains after the newline should be saved for a repetitive function call.**Requirements**
- Repeated calls (e.g., using a loop) to get_next_line() function should read the text file pointed to by the file descriptor, one line at a time.
- The function should return the line that was read. If there is nothing else to read or if an error occurred, it should return NULL.
- Function should work as expected both when reading a file and when reading from the standard input.
- The returned line should include the terminating \n character, except if the end of file was reached and does not end with a \n character.
- lseek() is forbidden.
- Global variables are forbidden.**Key learning points**
- Learning about file descriptors and reading from a file
- Using static variables## 🛠️ **Usage**
clone the repository:
```bash
git clone https://github.com/KHammerschmidt/42cursus-get_next_line &&
cd 42cursus-get_next_line &&
git clone https://github.com/KHammerschmidt/42cursus-Libft
```to modify the buffer size used by read() adapt BUFFERSIZE value n in
[`Makefile`](./Makefile) ``` CPPFLAGS := -D BUFFER_SIZE=n ```to compile the project:
```bash
make
```