This project involves the implementation of the get_next_line function, a function that reads a line from a file descriptor or standard input stream.
The get_next_line function reads a line (up to a newline character) from a file descriptor and stores this line in a dynamically allocated character string. With each function call, the next line of the file is read until a newline is found or the end of the file is reached.
- Clone this repository to your local machine.
git clone https://github.com/Lilien86/42-get_next_line.git
- Compile the program with the source files of the function (and your own main.c).
cc get_next_line.c get_next_line.h get_next_line_utils.c main.c
- Include the header file get_next_line.h and fcntl.h.
#include "get_next_line.h" #include "<fcntl.h>"
- Use the get_next_line function.
int main() { int fd = open("exemple.txt", O_RDONLY); char *line; while (get_next_line(fd, &line) > 0) { // Traitement de la ligne lue printf("Ligne lue : %s\n", line); free(line); } close(fd); return 0; }