Skip to content

This project will not only allow you to add a very convenient function to your collection, but it will also make you learn a highly interesting new concept in C programming: static variables.

Notifications You must be signed in to change notification settings

mouaammou/get_next_line-42

Repository files navigation

Get Next Line - 42 Project

Get Next Line - 42 Project

Table of Contents

Introduction

Get Next Line (GNL) is a project from the 42 school curriculum designed to develop a deeper understanding of file reading in C. The goal is to create a function that reads a line from a file descriptor, handling both memory management and edge cases effectively.

Project Overview

The Get Next Line project focuses on reading content from a file or input stream, one line at a time. This function will serve as a foundation for more complex input handling in future projects. You are tasked with writing a function that returns the next line from a file descriptor each time it is called.

Features

  • Read from any file descriptor, including standard input (stdin).
  • Handles multiple file descriptors simultaneously.
  • Efficient memory usage with buffers.
  • Customizable buffer size.
  • Handles different line-ending conventions.

Function Prototype

The core of the project is the get_next_line function:

char *get_next_line(int fd);

Parameters:

int fd: The file descriptor to read from.

Return Value:

char *: The function returns a line read from the file descriptor. The line includes the terminating newline character, except for the last line if it doesn’t end with a newline. Returns NULL if there are no more lines to read, or in case of an error.

About

This project will not only allow you to add a very convenient function to your collection, but it will also make you learn a highly interesting new concept in C programming: static variables.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages