Test with input file
This commit is contained in:
parent
aaac3125e9
commit
f595a3640f
2 changed files with 17 additions and 3 deletions
18
test001.c
18
test001.c
|
|
@ -6,26 +6,38 @@
|
|||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* 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 <stdio.h>
|
||||
#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(0);
|
||||
line = get_next_line(fd);
|
||||
printf("%s", line);
|
||||
stop = line == NULL;
|
||||
free(line);
|
||||
}
|
||||
if (fd > 0)
|
||||
close(fd);
|
||||
return (0);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue