-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_mandatory.c
40 lines (35 loc) · 1.32 KB
/
test_mandatory.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
38
39
40
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* test_mandatory.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fdi-cecc <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/04 18:27:25 by fdi-cecc #+# #+# */
/* Updated: 2024/06/04 18:39:41 by fdi-cecc ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
int main(int argc, char **argv)
{
if (argc != 2)
{
printf("Usage: %s <filename>\n", argv[0]);
return 1;
}
int fd = open(argv[1], O_RDONLY);
if (fd == -1)
{
perror("Error opening file");
return 1;
}
char *line;
while ((line = get_next_line(fd)) != NULL)
{
printf("%s", line);
free(line);
}
printf("\n");
close(fd);
return 0;
}