https://github.com/msabr/get_next_line_1337
A function that reads a file line by line, allowing efficient handling of input from files, stdin, or network streams.
https://github.com/msabr/get_next_line_1337
1337cursus 1337school 42cursus 42projects 42school c file-reading get- get-next-line-42 get-next-line-bonus get-next-line42 getnextline getnextline-42 getnextline42 static-variables
Last synced: 6 months ago
JSON representation
A function that reads a file line by line, allowing efficient handling of input from files, stdin, or network streams.
- Host: GitHub
- URL: https://github.com/msabr/get_next_line_1337
- Owner: msabr
- Created: 2025-02-19T11:02:34.000Z (8 months ago)
- Default Branch: master
- Last Pushed: 2025-03-12T02:25:33.000Z (7 months ago)
- Last Synced: 2025-03-12T03:27:23.297Z (7 months ago)
- Topics: 1337cursus, 1337school, 42cursus, 42projects, 42school, c, file-reading, get-, get-next-line-42, get-next-line-bonus, get-next-line42, getnextline, getnextline-42, getnextline42, static-variables
- Language: C
- Homepage:
- Size: 1.46 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# **get_next_line - 42 Network**
## **Overview**
Get Next Line delivers a function, `get_next_line()`, that retrieves a line from a file descriptor. It’s divided into two parts:
- **Mandatory Part**: A single function to read lines sequentially from a file descriptor or standard input.
- **Bonus Part**: Enhanced version supporting multiple file descriptors simultaneously with a single static variable.### Key Features
- Returns a line ending with `\n` (unless EOF is reached without it).
- Handles both file input and standard input efficiently.
- Uses static variables for state persistence across calls.
- Bonus: manages multiple file descriptors without mixing their reading threads.### Restrictions
- Written in C, adhering to the 42 Norm.
- No unexpected crashes (e.g., segmentation faults).
- No memory leaks from heap allocations.
- Compiled with `-Wall -Wextra -Werror` and `-D BUFFER_SIZE=n` (e.g., 42).
- No use of `libft`, `lseek()`, or global variables.## Getting Started
### Prerequisites
- C compiler (e.g., `clang` or `gcc`).
- `make` utility.### How to Build and Run
1. Clone the repository:
```bash
git clone https://github.com/msabr/GET_NEXT_LINE_1337
cd GET_NEXT_LINE_13372. Build the mandatory part:
```bash
cc -Wall -Wextra -Werror -D BUFFER_SIZE=42 get_next_line.c get_next_line_utils.c3. Build the bonus part (optional, separately):
```bash
cc -Wall -Wextra -Werror -D BUFFER_SIZE=42 get_next_line_bonus.c get_next_line_utils_bonus.c4. Run with a file or standard input:
```bash
./a.out## Project Structure
- `get_next_line.h`: function prototype for mandatory part.
- `get_next_line.c`: main function source.
- `get_next_line_utils.c`: helper functions.
- `get_next_line_bonus.h`: bonus function prototype.
- `get_next_line_bonus.c`: bonus main source.
- `get_next_line_utils_bonus.c`: bonus helper functions.