https://github.com/mathyscogne/42_get-next-line
Get Next Line is a 42 project that implements a function to read a line from a file descriptor
https://github.com/mathyscogne/42_get-next-line
42 gnl
Last synced: 7 months ago
JSON representation
Get Next Line is a 42 project that implements a function to read a line from a file descriptor
- Host: GitHub
- URL: https://github.com/mathyscogne/42_get-next-line
- Owner: MathysCogne
- Created: 2024-10-18T10:57:25.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-12-11T19:23:33.000Z (over 1 year ago)
- Last Synced: 2024-12-20T04:17:33.082Z (over 1 year ago)
- Topics: 42, gnl
- Language: C
- Homepage:
- Size: 2.76 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Description
Get Next Line (GNL) is a project to read a line from a file descriptor, returning it one line at a time.
The primary goal is to create a function that efficiently reads and returns lines from a file or standard input without memory leaks.
## Usage
To use the `get_next_line` function in your project, include the header file and call the function with a file descriptor:
```c
#include "get_next_line.h"
int main(void)
{
int fd;
char *line;
fd = open("your_file.txt", O_RDONLY);
while ((line = get_next_line(fd)) != NULL)
{
printf("%s\n", line);
free(line);
}
close(fd);
return (0);
}
```
## Disclaimer
> At 42 School, most projects must comply with the [Norm](https://github.com/42School/norminette/blob/master/pdf/en.norm.pdf).