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

https://github.com/abderrsfa/get_next_line

A function that reads from a file descriptor, standard input or standard output. Depending on how it is used, the function reads a single line or one line at a time until the End Of File.
https://github.com/abderrsfa/get_next_line

1337 42born2code file-descriptor get-next-line memory-allocation

Last synced: about 1 month ago
JSON representation

A function that reads from a file descriptor, standard input or standard output. Depending on how it is used, the function reads a single line or one line at a time until the End Of File.

Awesome Lists containing this project

README

          

# ↪️ get_next_line

## 🧐 Description
Get_next_line is a function that reads from a file, stdin or stdout and allows you to read one line from a file descriptor.
Calling the function once reads a single line from the file, and calling the function in a loop will allow you to read the file one line at a time until the EOF.
This project teaches a great deal on memory allocation. That is, when to allocate memory and when to free it in order to prevent memory leaks.

A (-1) is returned if an error occurred. A (0) is returned if the EOF is read. And a (1) is returned if a line is read.

## 🔧 Usage
You need to specify a BUFFER_SIZE of your choosing. To compile, use:

`gcc get_next_line.c get_next_line_utils.c -D BUFFER_SIZE= `