Skip to content

RaulSoftDev/get_next_line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

get_next_line

get_next_line is a 42 Madrid Common Core project in which you have to code a function that will return a line read from a file descriptor.

About the project

In this project you will have to code a function that when used in a loop will read and return all the lines from a file using its file descriptor.

Mandatory parts

  • Function protoype: char *get_next_line(int fd);
  • Your function must return the line read, NULL if reaches the end of file or returns error.
  • Your function have to work with files and with stdin.
  • Every line read from your function must end with the \n null char, except at the end of the file if it does not end with it.
  • The script must have a static variable BUFFER_SIZE to set the default buffer size.
  • The project must compile with the -D BUFFER_SIZE=XX flag but should have to compile without it.

Restrictions

  • The use of the libft library is forbidden.
  • The use of lseek is forbidden.
  • The use of global variables is forbidden.

Compilation

Requirements

  • C compiler: gcc, cc, etc...

Build project

  1. Clone the repository:

    git clone https://github.com/RaulSoftDev/get_next_line.git
  2. Use the function in your project:

    #include "get_next_line/get_next_line.h"
  3. Compile your project:

    gcc -Wall -Wextra -Werror -D BUFFER_SIZE=42 *.c