get_next_line
is a basic C function, which each time run on the same file descriptor returns the next line until the file descriptor returns EOL. It comes handy when reading from a file of getting user input from stdin
.
All you need is a C compiler.
Since this is just a simple function no build system required.
To use get_next_line
include the src file to src list to your compilation process.
main.c:
#include "get_next_line.h"
void main() {
int fd = open("/etc/passwd", O_RDONLY);
char *str = get_next_line(fd);
printf("%s\n", str);
}
This is a example using the basic version of get_next_line
.
gcc get_next_line.c get_next_line_utils.c main.c -D BUFFER_SIZE=<size> -o main
replace <size>
with the number of bytes to be read each time a read
system call is trigged.
- Using the standard version does not support reading from multiple file descriptor. To do so use the files ending with
_bonus
- Returned buffers is up to used to memory manage.
This project is licensed under MIT license. See the LICENSE file for details.