-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
37 lines (34 loc) · 1.25 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eblancha <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/19 14:18:31 by eblancha #+# #+# */
/* Updated: 2024/11/22 09:55:37 by eblancha ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd;
char *line;
fd = open(argv[1], O_RDONLY);
if (argc < 2)
return (0);
if (fd < 0)
{
write(2, "Error opening file", 18);
return (1);
}
while ((line = get_next_line(fd)) != NULL)
{
printf("-----------------Line : %s", line);
free(line);
}
close(fd);
return (0);
}