-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
43 lines (40 loc) · 1.41 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
38
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bnidia <bnidia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/12/23 14:13:42 by bnidia #+# #+# */
/* Updated: 2021/12/23 14:16:06 by bnidia ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <fcntl.h>
#include "get_next_line.h"
int main(void)
{
int fd1 = open("../test1.txt", O_RDONLY);
int fd2 = open("../test2.txt", O_RDONLY);
int fd3 = open("../test3.txt", O_RDONLY);
int i = 1;
while (i++ <= 2)
{
char *s1 = get_next_line(fd1);
printf("%s", s1);
free(s1);
char *s2 = get_next_line(fd2);
printf("%s", s2);
free(s2);
char *s3 = get_next_line(fd3);
printf("%s", s3);
free(s3);
}
if (fd1 > 0)
close(fd1);
if (fd2 > 0)
close(fd2);
if (fd3 > 0)
close(fd3);
return (0);
}