A C implementation that reads lines from a file descriptor, part of the WeThinkCode curriculum.
get_next_line is a function that sequentially reads lines from a file descriptor. Each call returns the next line ending with a newline character (\n). This project demonstrates efficient memory management and file I/O handling in C.
Year: 2019 | Language: C
- Reads lines from file descriptors one at a time
- Handles multiple file descriptors simultaneously
- Efficient memory allocation and deallocation
- Robust error handling
- GCC or Clang compiler
- Make
Clone the repository and navigate to the project:
git clone https://github.com/mikefmeyer/Get_Next_Line
cd Get_Next_Line/Compile the libft library and the get_next_line function:
# Build the library
make -C libft/ fclean && make -C libft/
# Compile get_next_line
clang -Wall -Werror -Wextra -I libft/includes -o get_next_line.o -c get_next_line.c
# Compile your test program
clang -Wall -Werror -Wextra -I libft/includes -o main.o -c main.c
# Link everything together
clang -o test_gnl main.o get_next_line.o -I libft/includes -L libft/ -lftRun the executable with the file you want to read:
./test_gnl [filename]get_next_line.c- Main function implementationget_next_line.h- Function declarations and headerslibft/- Custom C library with utility functions
This project is part of the WeThinkCode curriculum.