-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_bonus.c
54 lines (51 loc) · 1.52 KB
/
main_bonus.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: fmorenil <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/21 12:12:02 by fmorenil #+# #+# */
/* Updated: 2024/05/21 12:14:11 by fmorenil ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line_bonus.h"
#include <stdio.h>
int main(void)
{
int fd;
int fd2;
int i;
char *line;
char *line2;
fd = open("hello.txt", O_RDONLY);
fd2 = open("bye.txt", O_RDONLY);
if (fd == -1 || fd2 == -1)
{
printf("Error al abrir el archivo");
return (1);
}
i = 1;
while (1)
{
line = get_next_line(fd);
if (line != NULL)
{
printf("La linea %i de fd es: %s", i, line);
free(line);
}
line2 = get_next_line(fd2);
if (line2 != NULL)
{
printf("La linea %i de fd2 es: %s", i, line2);
free(line2);
}
i++;
if (line == NULL && line2 == NULL)
break ;
}
close(fd);
close(fd2);
printf("\n");
return (0);
}