Skip to content

Reading one line from a file descriptor with a varying BUFFER_SIZE.

Notifications You must be signed in to change notification settings

KHammerschmidt/42cursus-get_next_line

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 get_next_line


Reading a line from a file descriptor
Start date: 09/august/2021
Project status: completed 105/100 points

Github repo size Number of lines in code Languages used in repo Top used progamming language

💡 About the project

Write a project with maximum of 10 functions under the 42 norminette restrictions, that reads one line from a file descriptor with varying BUFFER_SIZE. Thereby, only one line should be returned and any remains after the newline should be saved for a repetitive function call.


Requirements

  • Repeated calls (e.g., using a loop) to get_next_line() function should read the text file pointed to by the file descriptor, one line at a time.
  • The function should return the line that was read. If there is nothing else to read or if an error occurred, it should return NULL.
  • Function should work as expected both when reading a file and when reading from the standard input.
  • The returned line should include the terminating \n character, except if the end of file was reached and does not end with a \n character.
  • lseek() is forbidden.
  • Global variables are forbidden.

Key learning points

  • Learning about file descriptors and reading from a file
  • Using static variables

🛠️ Usage

clone the repository:

git clone https://github.com/KHammerschmidt/42cursus-get_next_line &&
cd 42cursus-get_next_line &&
git clone https://github.com/KHammerschmidt/42cursus-Libft

to modify the buffer size used by read() adapt BUFFERSIZE value n in
Makefile CPPFLAGS := -D BUFFER_SIZE=n

to compile the project:

make

About

Reading one line from a file descriptor with a varying BUFFER_SIZE.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published