get_next_line_testing/test001.c
2025-10-29 19:35:19 +01:00

48 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test001.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/10/22 20:50:52 by lalgarra #+# #+# */
/* Updated: 2025/10/26 23:21:13 by lalgarra ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h> // printf()
#include <stdlib.h> // free()
#include <fcntl.h> // open()
#include <unistd.h> // close()
#include "get_next_line.h"
int main(int argc, char *argv[])
{
char *line;
int stop;
int fd;
(void) argc;
(void) argv;
fd = 0;
if (argc > 1)
fd = open(argv[1], O_RDONLY);
/*
if (fd < 0)
return (1);
*/
stop = 0;
while (!stop)
{
line = get_next_line(fd);
stop = line == NULL;
if (!stop)
{
printf("%s", line);
free(line);
}
}
if (fd > 0)
close(fd);
return (0);
}