From f595a3640f084fb6ad14b5f5e8b702feb38ec696 Mon Sep 17 00:00:00 2001 From: Leonardo Algarra Date: Sat, 25 Oct 2025 14:48:13 +0200 Subject: [PATCH] Test with input file --- input001 | 2 ++ test001.c | 18 +++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 input001 diff --git a/input001 b/input001 new file mode 100644 index 0000000..38d229b --- /dev/null +++ b/input001 @@ -0,0 +1,2 @@ +/* ************************************************************************** */ +/* \ No newline at end of file diff --git a/test001.c b/test001.c index a9e5af5..3872fa6 100644 --- a/test001.c +++ b/test001.c @@ -6,26 +6,38 @@ /* By: lalgarra +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/10/22 20:50:52 by lalgarra #+# #+# */ -/* Updated: 2025/10/24 14:34:28 by lalgarra ### ########.fr */ +/* Updated: 2025/10/25 13:58:21 by lalgarra ### ########.fr */ /* */ /* ************************************************************************** */ -#include +#include // printf() +#include // free() +#include // open() +#include // 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(0); + line = get_next_line(fd); printf("%s", line); stop = line == NULL; + free(line); } + if (fd > 0) + close(fd); return (0); }