🪡 Return the next line of given file descriptor every time you call the function
Get Next Line Project for ecole42. Because Reading a Line from a file descriptor is way too tedious. :)
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%
git clone https://github.com/peguimasid/42-GNL get_next_line
- 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?
- 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);
}
gcc get_next_line.c get_next_line.h get_next_line_utils.c main.c && ./a.out
👤 Lohan Guedes
- Github: @lguedes
- LinkedIn: @lohan-guedes
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!