Skip to content

TheJocker94/ft_get_next_line_42

Repository files navigation

Get_next_line_42

Reading a single line from a file

Get Next Line Project

Overview

The objective of this project is to create a function that reads and returns a line from a file descriptor. This project is particularly insightful as it introduces a new intriguing concept in C programming: static variables.

How to Use

  1. Clone this repository:
  2. git clone https://github.com/TheJocker94/ft_get_next_line_42.git
  3. Compile the source code with your desired buffer size (e.g., 42) using the following command:
  4. gcc -Wall -Wextra -Werror -D BUFFER_SIZE=42 *.c

Features

The main function, get_next_line(int fd), returns a line from the file descriptor passed to it.

  • If successful, the function returns the read line.
  • If there is nothing else to read or an error occurred, the function returns NULL.
  • The function works with any file as well as the standard input.
  • The returned line will include the terminating \n character, unless the end of file is reached without a final \n character.

Multiple calls to get_next_line() in a loop will allow you to read the entire text file, line by line. Additionally, the function has been optimized to read as little as possible with each call, efficiently processing each line.

Enjoy utilizing my Get Next Line implementation in your programming endeavors! :)

About

Reading a single line from a file

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages