/Get-Next-Line

Get next line project from ecole42 - Because Reading a line from a File descriptor is too Tedious

Primary LanguageC

Welcome to GNL 👋

🪡 Return the next line of given file descriptor every time you call the function

GNL

Get Next Line Project for ecole42. Because Reading a Line from a file descriptor is way too tedious. :)

Goals:

This Project will allow me to add a very convenient function to my collection. libft but will also make me learn Static Variables and how to work with them.


  • Status: Finished
  • Result: 125%

Install

git clone https://github.com/peguimasid/42-GNL get_next_line

Usage

  1. Inside project dir create a text file (file.txt)
this is the first line
this is the second line
how many times you gonna call me?
  1. Create a main.c file
#include "get_next_line.h"
#include <fcntl.h>
#include <stdio.h>

int	main(void)
{
	int	fd;

	fd = open("file.txt", O_RDONLY);
	printf("%s", get_next_line(fd)); // this is the first line
	printf("%s", get_next_line(fd)); // this is the second line
	printf("%s", get_next_line(fd)); // how many times you gonna call me?
	close(fd);
}

Run

gcc get_next_line.c get_next_line.h get_next_line_utils.c main.c && ./a.out

Author

👤 Lohan Guedes

Show your support

Feel free to fork this project and send a pull request to it! I would love to see possible improvements ❤️‍🩹. Give a ⭐ if this project helped you!