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.
- Host: GitHub
- URL: https://github.com/abderrsfa/get_next_line
- Owner: AbderrSfa
- License: apache-2.0
- Created: 2020-06-12T01:30:17.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-09T16:46:15.000Z (over 4 years ago)
- Last Synced: 2024-12-27T17:16:08.659Z (12 months ago)
- Topics: 1337, 42born2code, file-descriptor, get-next-line, memory-allocation
- Language: C
- Homepage:
- Size: 1.21 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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= `