get_next_line/test.c
2024-10-24 12:38:36 +02:00

42 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/24 11:51:57 by kcolin #+# #+# */
/* Updated: 2024/10/24 11:59:09 by kcolin ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd;
char *line;
if (argc == 2)
{
fd = open(argv[1], O_RDONLY);
line = "";
while (line != NULL)
{
line = get_next_line(fd);
if (line != NULL)
{
printf("%s", line);
free(line);
}
}
return (0);
}
else
{
printf("Usage: %s <path>\n", argv[0]);
return (1);
}
}