Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

get_next_line

Objective

get_next_line is a function that reads a file descriptor line by line.
The goal of the project is to learn how to handle dynamic memory allocation, manage buffers, and efficiently read files in C.


Usage

To compile the project:

cc -Wall -Wextra -Werror -D BUFFER_SIZE=42 -c get_next_line.c
cc -Wall -Wextra -Werror -D BUFFER_SIZE=42 -c get_next_line_utils.c
cc -o gnl_test get_next_line.o get_next_line_utils.o

How it Works

get_next_line works by:

  1. Reading from a file descriptor into a buffer of size BUFFER_SIZE.
  2. Storing any leftover content for the next call.
  3. Extracting and returning one line at a time, including the newline character.
  4. Managing memory dynamically to handle any line length.

Recap

  • Handling file descriptors and low-level I/O in C.
  • Using buffers to read data efficiently.
  • Managing dynamic memory allocation and freeing memory correctly.
  • Handling edge cases such as empty files or very long lines.
  • Strengthening understanding of C fundamentals and memory management.

About

`get_next_line` is a function that reads a file descriptor **line by line**. The goal of the project is to learn how to handle dynamic memory allocation, manage buffers, and efficiently read files in C.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages