Skip to content
This repository was archived by the owner on Jun 4, 2026. It is now read-only.

Latest commit

 

History

46 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

get_next_line

Buffered C line reader for UNIX file descriptors.

CI C Make License

Overview

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.

API

int get_next_line(const int fd, char **line);

Return values:

Value Meaning
1 A line was read
0 End of file
-1 Error

Build and Run

git clone https://github.com/itkrivoshei/get-next-line-c.git
cd get-next-line-c
make
./get_next_line path/to/file.txt

Read from standard input:

./get_next_line < path/to/file.txt

Change the buffer size at compile time:

make CFLAGS="-Wall -Wextra -Werror -DBUFF_SIZE=128"

Make Targets

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

Repository Layout

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

Automation

  • ci.yml builds the project and runs the smoke test through GitHub Actions.

License

GPL-3.0

About

Buffered C line reader for UNIX file descriptors with Make targets, libft helpers, smoke tests, and CI.

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Used by

Contributors

Languages