Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/timhopg/42-get_next_line
A 42 School Lisboa project to retrieve the next line from a file descriptor
https://github.com/timhopg/42-get_next_line
42school clang files static-variable
Last synced: 2 days ago
JSON representation
A 42 School Lisboa project to retrieve the next line from a file descriptor
- Host: GitHub
- URL: https://github.com/timhopg/42-get_next_line
- Owner: TimHopg
- Created: 2024-05-09T14:50:56.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2024-09-19T09:15:18.000Z (4 months ago)
- Last Synced: 2024-11-13T21:16:09.032Z (2 months ago)
- Topics: 42school, clang, files, static-variable
- Language: C
- Homepage:
- Size: 2.94 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 42-get_next_line
![get_next_line grade](./get_next_line_grade.png)
## Table of Contents
- [Introduction](#introduction)
- [Installation](#installation)
- [Usage](#usage)
- [Implementation](#implementation)## Introduction
A [42 School](https://www.42network.org/) project to retrieve the next line from a given file descriptor.
## Installation
Git clone the repository:
```shell
https://github.com/TimHopg/42-Get-Next-Line.git
```A `main.c` is included with various tests and edge cases as well as a variety of `txt` files.
## Usage
No `makefile` with this project. The function can be utilised within your own project.
Compile as follows:
`cc -Wall -Wextra -Werror -D BUFFER_SIZE=n [files].c`Where `n` can be a buffer size of your choice. If not `BUFFER-SIZE` is set, the value in the header file is used.
## Implementation
Initially I utilised linked lists to undertake this project but it's both unnecessary and not an optimal solution. The single allowed static variable is sufficient to store the buffer string and a dynamically allocated string can be used to read from the file. A secondary logic has been adapted in `logic2` based on Laher Wenceslau Payot Maciel's work, which is more streamlined but has some limitations when sending invalid file descriptors.