get_next_line reads one line at a time from a UNIX file descriptor.
The implementation keeps unread data in a static per-file-descriptor buffer and reads chunks of BUFF_SIZE bytes until it reaches a newline, end of file, or an error.
int get_next_line(const int fd, char **line);Return values:
| Value | Meaning |
|---|---|
1 |
A line was read |
0 |
End of file |
-1 |
Error |
git clone https://github.com/itkrivoshei/get-next-line-c.git
cd get-next-line-c
make
./get_next_line path/to/file.txtRead from standard input:
./get_next_line < path/to/file.txtChange the buffer size at compile time:
make CFLAGS="-Wall -Wextra -Werror -DBUFF_SIZE=128"Targets are defined in Makefile.
| Target | Description |
|---|---|
make |
Build the get_next_line executable |
make test |
Run a smoke test for file and stdin input |
make clean |
Remove object files |
make fclean |
Remove objects and executable |
make re |
Rebuild from scratch |
| Path | Purpose |
|---|---|
get_next_line.c |
Line-reading implementation |
get_next_line.h |
Public function declaration and constants |
main.c |
CLI smoke runner |
libft/ |
Bundled support library |
Makefile |
Build, clean, and smoke-test targets |
ci.ymlbuilds the project and runs the smoke test through GitHub Actions.