The aim of this project is to make you code a function that returns a line ending with a newline, read from a file descriptor.
We are allowed to use the following functions:
- read()
- malloc()
- free()
Note:. The respective prototypes can be found at the bottom of this file.
char *get_next_line(int fd) (newer version)
int get_next_line(int fd, char **line) (older version)
- Read line --> correct behavior
- NULL ---> nothing else to read or an error occurred
gcc -Wall -Wextra -Werror -D BUFFER_SIZE=xx get_next_line.c get_next_line_utils.c
BUFFER_SIZE should be defined by the evaluator
- get_next_line.c
- get_next_line_utils.c
- get_next_line.h
- get_next_line_bonus.c
- get_next_line_utils_bonus.c
- get_next_line_bonus.h
Since we can't use the libft on this project, I had to include the following functions inside the utils file.
Each of these can be found inside Libft project.
ssize_t read(int fd, void *buf, size_t n_bytes) ~ ex. char *buffer; read(fd, buffer, 20); --> read 20 bytes or 20 chars
void *malloc(size_t size) ~ ex. buffer = malloc((20 + 1) * sizeof(char));
void free(void *ptr) ~ ex. free(buffer);