An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          


42 Get Next Line (GNL)


Because putnbr and putstr aren’t enough


Subject

## 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).