Skip to content

hceviz/get_next_line

Repository files navigation

get_next_line

Project Overview

get_next_line is a project from 42 School designed to develop a function that reads a file descriptor line by line, returning one line per call without loading the entire file into memory.

Description

The goal of this project is to write a function get_next_line that reads from a file descriptor and returns the next line each time it is called. It handles reading arbitrarily long lines efficiently by reading the file in chunks defined by BUFFER_SIZE.

Features

  • Reads one line at a time from a file descriptor
  • Supports multiple file descriptors simultaneously (in bonus part)
  • Handles files of any size without memory overflow
  • Works with any BUFFER_SIZE value

Installation

1. Clone this repository
2. Compile the code with your preferred C compiler:
gcc -Wall -Wextra -Werror -D BUFFER_SIZE=42 get_next_line.c get_next_line_utils.c -o gnl

File Structure

  • get_next_line.c — main function implementation
  • get_next_line_utils.c — helper functions
  • get_next_line.h — header file with function prototypes and macros
  • Bonus part is very similar with mandatory except bonus part handles multiple file descriptors simultaneously.

Project Constraints

  • Used only allowed functions: read(), malloc(), and free()
  • No leaks or crashes — memory is managed carefully
  • The function is efficient and handles edge cases

About

gnl

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages