Skip to content

A C implementation that reads lines from a file descriptor, part of the WeThinkCode curriculum.

Notifications You must be signed in to change notification settings

devwithmike/GNL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get Next Line

A C implementation that reads lines from a file descriptor, part of the WeThinkCode curriculum.

Overview

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

Features

  • Reads lines from file descriptors one at a time
  • Handles multiple file descriptors simultaneously
  • Efficient memory allocation and deallocation
  • Robust error handling

Getting Started

Prerequisites

  • GCC or Clang compiler
  • Make

Installation

Clone the repository and navigate to the project:

git clone https://github.com/mikefmeyer/Get_Next_Line
cd Get_Next_Line/

Compilation

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/ -lft

Usage

Run the executable with the file you want to read:

./test_gnl [filename]

Project Structure

  • get_next_line.c - Main function implementation
  • get_next_line.h - Function declarations and headers
  • libft/ - Custom C library with utility functions

License

This project is part of the WeThinkCode curriculum.

About

A C implementation that reads lines from a file descriptor, part of the WeThinkCode curriculum.

Topics

Resources

Stars

Watchers

Forks